Skip to content

Commit

Permalink
Merge pull request orbisgis#735 from gpetit/ST_GeomFromGeoJSON
Browse files Browse the repository at this point in the history
Add a doc for ST_GeomFromGML function
  • Loading branch information
ebocher authored Dec 6, 2016
2 parents a3340d0 + 5ac05b3 commit 91ab080
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/dev/ST_Force2D.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ category: geom2D/geometry-conversion
is_function: true
description: 3D Geometry → 2D Geometry
prev_section: ST_AsWKT
next_section: ST_GeomFromText
next_section: ST_GeomFromGML
permalink: /docs/dev/ST_Force2D/
---

Expand Down
108 changes: 108 additions & 0 deletions docs/dev/ST_GeomFromGML.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
layout: docs
title: ST_GeomFromGML
category: geom2D/geometry-conversion
is_function: true
description: GML → Geometry
prev_section: ST_Force2D
next_section: ST_GeomFromText
permalink: /docs/dev/ST_GeomFromGML/
---

### Signature

{% highlight mysql %}
GEOMETRY ST_GeomFromGML(VARCHAR gml);
GEOMETRY ST_GeomFromGML(VARCHAR gml, INT srid);
{% endhighlight %}

### Description

Converts an input `gml` representation into a Geometry, optionally with spatial reference id `srid`.

This function supports:

* only GML 2.1.2
* 3D coordinates
* Multi-geometries

### Examples

##### For a Point, with a srid
{% highlight mysql %}
SELECT ST_GeomFromGML('
<gml:Point>
<gml:coordinates>
50.2,38.7
</gml:coordinates>
</gml:Point>', 4326);
-- Answer: POINT (50.2 38.7)
{% endhighlight %}

##### For a 3D Point
{% highlight mysql %}
SELECT ST_GeomFromGML('
<gml:Point>
<gml:coordinates>
50.2,38.7,20
</gml:coordinates>
</gml:Point>');
-- Answer: POINT (50.2 38.7 20)
{% endhighlight %}

##### For a Linestring
{% highlight mysql %}
SELECT ST_GeomFromGML('
<gml:LineString srsName="EPSG:4326">
<gml:coordinates>
-60.5,35.2 -62.3,47.4 -65.6,48.4
</gml:coordinates>
</gml:LineString>');
-- Answer: LINESTRING (-60.5 35.2, -62.3 47.4, -65.6 48.4)
{% endhighlight %}

##### For a MultiLinestring
{% highlight mysql %}
SELECT ST_GeomFromGML('
<MultiLineString srsName="EPSG:4326">
<lineStringMember>
<LineString>
<coordinates>56.1,0.45 67.23,0.67</coordinates>
</LineString>
</lineStringMember>
<lineStringMember>
<LineString>
<coordinates>46.71,9.25 56.88,10.44</coordinates>
</LineString>
</lineStringMember>
<lineStringMember>
<LineString>
<coordinates>324.1,219.7 0.45,0.56</coordinates>
</LineString>
</lineStringMember>
</MultiLineString>');
-- Answer: MULTILINESTRING ((56.1 0.45, 67.23 0.67),
-- (46.71 9.25, 56.88 10.44),
-- (324.1 219.7, 0.45 0.56))
{% endhighlight %}

##### For a Polygon
{% highlight mysql %}
SELECT ST_GeomFromGML('
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>
0,0 50,0 50,50 0,50 0,0
</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>');
-- Answer: POLYGON ((0 0, 50 0, 50 50, 0 50, 0 0))
{% endhighlight %}

##### See also

* [`ST_AsGML`](../ST_AsGML)

* <a href="https://github.com/orbisgis/h2gis/blob/master/h2gis-functions/src/main/java/org/h2gis/functions/spatial/convert/ST_GeomFromGML.java" target="_blank">Source code</a>
2 changes: 1 addition & 1 deletion docs/dev/ST_GeomFromText.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: ST_GeomFromText
category: geom2D/geometry-conversion
is_function: true
description: Well Known Text &rarr; Geometry
prev_section: ST_Force2D
prev_section: ST_GeomFromGML
next_section: ST_GeomFromWKB
permalink: /docs/dev/ST_GeomFromText/
---
Expand Down

0 comments on commit 91ab080

Please sign in to comment.