pom依赖:
<dependency>
<groupId>com.esri.geometry</groupId>
<artifactId>esri-geometry-api</artifactId>
<version>2.2.4</version>
</dependency>
package com.kingoit.cgdb;
import com.esri.core.geometry.Geometry;
import com.esri.core.geometry.GeometryEngine;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.geometry.WktExportFlags;
import org.junit.jupiter.api.Test;
public class Test2 {
@Test
void test1(){
//方式一
String ring = "{\"rings\":[[[115.050294206119,35.1199055993831],[115.050099166593,35.1199016203711],[115.050100226036,35.1201261411213],[115.050290135392,35.1201269913101],[115.050294206119,35.1199055993831]]]}";
Geometry geometry = GeometryEngine.jsonToGeometry(ring).getGeometry();
//rings转wkt
//String wktStr = GeometryEngine.geometryToWkt(geometry, WktExportFlags.wktExportDefaults);
//System.out.println(wktStr);
String wktStr = "MULTIPOLYGON(((104.319548532 36.3818405920001,104.319637531 36.381925116,104.319643962 36.38193039,104.319813536 36.3819722870001,104.320043129 36.3817647220001,104.320045012 36.381548455,104.319822444 36.381511141,104.319599091 36.381563939,104.319568273 36.381732576,104.319548532 36.3818405920001)))";
Geometry geometry1 = GeometryEngine.geometryFromWkt(wktStr, WktExportFlags.wktExportDefaults, Geometry.Type.Unknown);
//方式一
String s = GeometryEngine.geometryToJson(4326, geometry1);
System.out.println(s);
//方式二
String s1 = GeometryEngine.geometryToJson(SpatialReference.create(wktStr), geometry1);
System.out.println(s1);
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)