geojson输出
2021-06-27 21:05
标签:list new eve return ack obj file 包括 color 结果: geojson输出 标签:list new eve return ack obj file 包括 color 原文地址:http://www.cnblogs.com/unique1319/p/7145296.htmlimport java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class GeoJsonOutput {
/**
* geoJson
* 包括 features 和 type
*/
Map
public void jsonOutPut(Map map) {
ObjectMapper mapper = new ObjectMapper();
try{
mapper.writeValue(new File("D:/geoJsonTest.json"), map);
}catch (Exception e){
e.printStackTrace();
}
}
public class Test3 {
public static void main(String[] args){
GeoJsonOutput go = new GeoJsonOutput();
/*填充 coordinates*/
List
> coordiantes = new ArrayList();
coordiantes.add(go.fillCoordnate(104.63227074146543,28.769242770389777,0));
coordiantes.add(go.fillCoordnate(104.64619058834954,28.77423963850202,0));
coordiantes.add(go.fillCoordnate(104.66260886928977,28.76246130652316,0));
/*填充 features*/
List
{
"features": [
{
"geometry": {
"coordinates": [
[
104.63227074146543,
28.769242770389777,
0
],
[
104.64619058834954,
28.77423963850202,
0
],
[
104.66260886928977,
28.76246130652316,
0
]
],
"type": "LineString"
},
"type": "Feature",
"properties": {
"color": "#FF0000",
"lever": "4"
}
},
{
"geometry": {
"coordinates": [
[
104.63227074146543,
28.769242770389777,
0
],
[
104.64619058834954,
28.77423963850202,
0
],
[
104.66260886928977,
28.76246130652316,
0
]
],
"type": "LineString"
},
"type": "Feature",
"properties": {
"color": "#00FF00",
"lever": "3"
}
},
{
"geometry": {
"coordinates": [
[
104.63227074146543,
28.769242770389777,
0
],
[
104.64619058834954,
28.77423963850202,
0
],
[
104.66260886928977,
28.76246130652316,
0
]
],
"type": "LineString"
},
"type": "Feature",
"properties": {
"color": "#FF0000",
"lever": "2"
}
},
{
"geometry": {
"coordinates": [
[
104.63227074146543,
28.769242770389777,
0
],
[
104.64619058834954,
28.77423963850202,
0
],
[
104.66260886928977,
28.76246130652316,
0
]
],
"type": "LineString"
},
"type": "Feature",
"properties": {
"color": "#00FF00",
"lever": "1"
}
}
],
"type": "FeatureCollection"
}
上一篇:php-7.0.18版本(编译安装)-自定义安装路径
下一篇:PHP 语法