Standard format for point-line-surface data
First, Point
WKT:
Point ( -118.4-45.2)
Json:
{
"X":-118.4,
"Y":-45.2,
"Spatialreference": {
"Wkid": 4326
}
}
Second, Multi-point
WKT:
MULTIPOINT (1.01 2.02, 2.01 3.01)
Note: This structure differs from the OGC standard, which is the structure of SQLite's geometry.
OGC Standard: MULTIPOINT ((1.01 2.02), (2.01 3.01))
Json:
{
"Points": [
[
1.01,
2.02
],
[
2.01,
3.01
]
],
"Spatialreference": {
"Wkid": 4326
}
}
Third, Line
WKT:
LINESTRING (668540.706869 4858267.857562, 668545.871539 4858270.322537, 668535.504206 4858270.059492)
Json:
{
"Paths": [
[
[
668540.706869,
4858267.857562
],
[
668545.871539,
4858270.322537
],
[
668535.504206,
4858270.059492
]
]
],
"Spatialreference": {
"Wkid": 102100
}
}
Four, Multi-righteousness line
WKT:
Multilinestring ((668540.706869 4858267.857562,668545.871539 4858270.322537), (668535.504206 4858270.059492, 668535.504206 4858270.059492))
Json:
{
"Rings": [
[
[
668540.706869,
4858267.857562
],
[
668545.871539,
4858270.322537
]
],
[
[
668535.504206,
4858270.059492
],
[
668535.504206,
4858270.059492
]
]
],
"Spatialreference": {
"Wkid": 102100
}
}
Five, Polygon
Note: Polygon Two point coordinates are the same.
WKT:
POLYGON (10172081.707086032 3426616.2980572497,10181098.35305895 3439876.071546833,10188842.060776865 3423858.265171416,10172081.707086032 3426616.2980572497))
Json:
{
"Rings": [
[
[
10172081.707086032,
3426616.2980572497
],
[
10181098.35305895,
3439876.071546833
],
[
1266114.9310351424,
3430468.042044999
],
[
10188842.060776865,
3423858.265171416
] ,
[
10172081.707086032,
3426616.2980572497
]
]
],
"Spatialreference": {
"Wkid": 102100
}
}
Six, Multi-Polygon
WKT:
Multipolygon (((752912.250297 5028764.989051, 753066.871935 5028928.677375, 753417.249537 5028775.949135, 753828.826422 5027429.54477, 752992.3308 5028072.927877, 752912.250297 5028764.989051)))
Json:
{
"Rings": [
[
[
752912.250297,
5028764.989051
],
[
753066.871935,
5028928.677375
],
[
753417.249537,
5028775.949135
],
[
753828.826422,
5027429.54477
],
[
752992.3308,
5028072.927877
],
[
752912.250297,
5028764.989051
]
]
],
"Spatialreference": {
"Wkid": 102100
}
}
Practical Application Development
1) conversion of WKT and JSON format to each other.
WKT to JSON method: String Wkt.read (String wktsr)
JSON to WKT Method: String Wkt.write (String jsonstr)
2) based on 1th, the wkt can be generated from ArcGIS for Android geometry geometry.
Read the wkt string of geometry from the Spatialite database:
SELECT astext (geometry) from test
Convert the WKT string to JSON and convert the JSON to a geometry object through the Geometryengine Jsontogeometry method.
String str= "{\" rings\ ": [[[[1007664.4779535953,3710553.4649297176],[957962.4793888753,3190110.978805308],[ 1266114.9310351424,3430468.042044999],[1007664.4779535953,3710553.4649297176]]],\ "spatialReference\": {\ "wkid\" : 102100}} ";
Jsonfactory jsonfactory = new Jsonfactory ();
try {
Jsonparser jsonparser = Jsonfactory.createjsonparser (str);
Mapgeometry Mapgeo = Geometryengine.jsontogeometry (Jsonparser);
Geometry geo = Mapgeo.getgeometry ();
} catch (Jsonparseexception e) {
TODO auto-generated Catch block
E.printstacktrace ();
} catch (IOException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
3) storing ArcGIS for Android Geomtery in a spatial database spatialite , I mean storing spatial data instead of wkt strings.
The JSON string is generated by Geometryengine's Geometrytojson method, which is converted to wkt and then inserted into the spatial database.
Insert multipoint data into the Spatialite database:
INSERT into Test (geometry) VALUES (Geomfromtext (' MULTIPOINT (1.01 2.02, 2.01 3.01) ', 4326))
Arcgis for Android spatial data wkt and JSON description