If i make a query on my postgis database to get my districts, i get the following returned for my LatLon column:
SELECT id, ST_AsText(latlon) AS geom FROM district;
MULTIPOLYGON(((16.4747103091463 48.2753153528078,16.4744319731163 48.275314069121,16.4743511374383 48.2753128173411,16.4743147576862 48.2753108825757,16.474247514683 48.275304398381,16.474205201686 48.2753004022899)))
But how am i supposed to work with this in my java android app?
The structure seems not to be correct.. Because if i want to start working with it.. i first have to cut out the parentheses and then the "MULTIPOLYGON". This seems not very comfortable too me...
Shouldnt it be more like the following? If yes, how can i achieve this kind of output format?
{ "type": "MultiPolygon",
"coordinates": [
[[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],
[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
]
}
ST_AsText converts to Well-known text , while ST_AsGeoJSON converts to GeoJSON . Try:
SELECT id, ST_AsGeoJSON(latlon) AS geom FROM district;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.