Arcgis for Android 空間資料WKT與JSON描述

來源:互聯網
上載者:User

點線面資料標準格式

一、

WKT:

POINT(-118.4 -45.2)

JSON:

{

"x": -118.4,

"y": -45.2,

"spatialReference": {

"wkid": 4326

}

}

二、 多點

WKT:

MULTIPOINT(1.01 2.02, 2.01 3.01)

注意:這個結構與OGC標準不同,這是sqlite的幾何體的結構。

OGC標準: MULTIPOINT( (1.01 2.02), (2.01 3.01))

JSON:

{

"points": [

[

1.01,

2.02

],

[

2.01,

3.01

]

],

"spatialReference": {

"wkid": 4326

}

}

 

三、

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

}

}

四、 多義線

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

}

}

五、 多邊形

注意: 多邊形首尾兩點座標是相同的。

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

}

}

 

六、 多多邊形

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

}

}

 

實際應用開發

1) WKT與JSON格式的相互轉換。

WKT轉成JSON方法: String WKT.read(String wktsr)

JSON轉成WKT方法: String WKT.write(String jsonstr)

2) 基於第一點可將WKT產生Arcgis for Android 的幾何體Geometry

從Spatialite資料庫讀取幾何體的WKT字串:

SELECT ASTEXT(geometry) FROM test

將WKT字串轉成JSON,通過GeometryEngine的jsonToGeometry方法將JSON轉成Geometry對象。

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) 將Arcgis for android Geomtery 存入空間資料庫Spatialite中,我是指存入空間資料而不是WKT字串。

JSON字串是通過GeometryEngine的geometryToJson方法產生,轉成WKT後再插入空間資料庫。

將多點資料插入Spatialite資料庫:

INSERT INTO test ( geometry) VALUES(GeomFromText('MULTIPOINT(1.01 2.02, 2.01 3.01)', 4326))

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.