Standard Data Format
I,Point
WKT:
Point (-118.4-45.2)
JSON:
{
"X":-118.4,
"Y":-45.2,
"Spatialreference ":{
"Wkid": 4326
}
}
II,Multi-Point
WKT:
Multipoint (1.01 2.02, 2.01 3.01)
Note: This structure is different from the OGC standard, which is the structure of the SQLite ry.
OGC standard: multipoint (1.01 2.02), (2.01 3.01 ))
JSON:
{
"Points ":[
[
1.01,
2.02
],
[
2.01,
3.01
]
],
"Spatialreference ":{
"Wkid": 4326
}
}
III,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
}
}
IV,Definition 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
}
}
V,Polygon
Note:The two coordinates at the beginning and end of a polygon 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
}
}
VI,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)WKTAnd JSONFormat conversion.
Method for converting WKT to JSON: String WKT. Read (string wktsr)
JSON to WKT method: String WKT. Write (string jsonstr)
2)Based on the first point, you can set WKTGenerate ArcGIS for AndroidRy.
Read the WKT string of the Ry from the spatialite database:
Select astext (geometry) from test
Convert the WKT string to JSON and convert the JSON string to a ry object through the jsontogeometry method of geometryengine.
String STR = "{\" rings \ ": [[1007664.4779535953, 3710553.4649297176], [957962.4793888753, 3190110.978805308], [1266114.9310351424, 3430468.042044999], \ "spatialreference \": {\ "wkid \": 102100 }}";
Jsonfactory = new jsonfactory ();
Try {
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)Set ArcGIS for Android geomterySaved to the spatial database spati.pdfIn, I mean to store space data instead of WKTString.
The JSON string is generated by geometrytojson of geometryengine. It is converted to WKT and then inserted into the spatial database.
Insert multi-point data into the spati.pdf database:
Insert into test (geometry) values (geomfromtext ('multipoint (1.01 2.02, 2.01 3.01) ', 4326 ))