Skip to content

Commit

Permalink
Merge pull request orbisgis#964 from gpetit/gh-pages
Browse files Browse the repository at this point in the history
update GeoJsonWrite doc
  • Loading branch information
ebocher authored Feb 21, 2019
2 parents 233ba2b + 37292dd commit a7ee05f
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion docs/dev/GeoJsonWrite.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,47 @@ permalink: /docs/dev/GeoJsonWrite/

{% highlight mysql %}
GeoJsonWrite(VARCHAR path, VARCHAR tableName);
GeoJsonWrite(VARCHAR path, VARCHAR tableName, VARCHAR fileEncoding);
{% endhighlight %}

### Description

Writes table `tableName` to a [GeoJSON][wiki] file located at
Writes the contents of table `tableName` to a [GeoJSON][wiki] file located at
`path`.

`tableName` can be either:

* the name of an existing table,
* the result of a query (`SELECT` instruction which has to be written between simple quote and parenthesis `'( )'`).

The default value of `fileEncoding` is `ISO-8859-1`.

### Examples

{% highlight mysql %}
-- Write a spatial table to a GeoJSON file:
CREATE TABLE TEST(ID INT PRIMARY KEY, THE_GEOM POINT);
INSERT INTO TEST VALUES (1, 'POINT(0 1)');
INSERT INTO TEST VALUES (2, 'POINT(2 4)');

CALL GeoJsonWrite('/home/user/test.geojson', 'TEST');

-- Read it back:
CALL GeoJsonRead('/home/user/test.geojson', 'TEST2');
SELECT * FROM TEST2;
-- Answer:
-- | THE_GEOM | ID |
-- |-------------|----|
-- | POINT(0 1) | 1 |
-- | POINT(2 4) | 2 |
{% endhighlight %}

#### Case where `tablename` is the result of a selection

{% highlight mysql %}
CALL GeoJsonWrite('/home/user/test.geojson',
'(SELECT * FROM TEST WHERE ID<2 )');

-- Read it back:
CALL GeoJsonRead('/home/user/test.geojson', 'TEST2');
SELECT * FROM TEST2;
Expand Down

0 comments on commit a7ee05f

Please sign in to comment.