本文整理汇总了Java中com.esri.core.geometry.ogc.OGCGeometry.fromGeoJson方法的典型用法代码示例。如果您正苦于以下问题:Java OGCGeometry.fromGeoJson方法的具体用法?Java OGCGeometry.fromGeoJson怎么用?Java OGCGeometry.fromGeoJson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.esri.core.geometry.ogc.OGCGeometry
的用法示例。
在下文中一共展示了OGCGeometry.fromGeoJson方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
DeferredObject jsonDeferredObject = arguments[0];
String json = null;
if (jsonOI.getCategory() == Category.STRUCT){
//StructObjectInspector structOI = (StructObjectInspector)jsonOI;
// TODO support structs
} else {
PrimitiveObjectInspector primOI = (PrimitiveObjectInspector)jsonOI;
json = (String)primOI.getPrimitiveJavaObject(jsonDeferredObject.get());
}
try {
OGCGeometry ogcGeom = OGCGeometry.fromGeoJson(json);
return GeometryUtils.geometryToEsriShapeBytesWritable(ogcGeom);
} catch (Exception e) {
LogUtils.Log_InvalidText(LOG, json);
}
return null;
}
示例2: testPolygon
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
@Test
public void testPolygon() throws Exception {
OGCGeometry g = OGCGeometry
.fromText("POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10), (-5 -5, -5 5, 5 5, 5 -5, -5 -5))");
assertTrue(g.geometryType().equals("Polygon"));
OGCPolygon p = (OGCPolygon) g;
assertTrue(p.numInteriorRing() == 1);
OGCLineString ls = p.exteriorRing();
// assertTrue(ls.pointN(1).equals(OGCGeometry.fromText("POINT(10 -10)")));
boolean b = ls
.Equals(OGCGeometry
.fromText("LINESTRING(-10 -10, 10 -10, 10 10, -10 10, -10 -10)"));
assertTrue(b);
OGCLineString lsi = p.interiorRingN(0);
b = lsi.Equals(OGCGeometry
.fromText("LINESTRING(-5 -5, -5 5, 5 5, 5 -5, -5 -5)"));
assertTrue(b);
b = lsi.equals((Object)OGCGeometry
.fromText("LINESTRING(-5 -5, -5 5, 5 5, 5 -5, -5 -5)"));
assertTrue(!lsi.Equals(ls));
OGCMultiCurve boundary = p.boundary();
String s = boundary.asText();
assertTrue(s.equals("MULTILINESTRING ((-10 -10, 10 -10, 10 10, -10 10, -10 -10), (-5 -5, -5 5, 5 5, 5 -5, -5 -5))"));
{
OGCGeometry g2 = OGCGeometry.fromGeoJson(
"{\"type\": \"Polygon\", \"coordinates\": [[[1.00000001,1.00000001], [4.00000001,1.00000001], [4.00000001,4.00000001], [1.00000001,4.00000001]]]}");
OGCGeometry
.fromGeoJson(
"{\"type\": \"LineString\", \"coordinates\": [[1.00000001,1.00000001], [7.00000001,8.00000001]]}")
.intersects(g2);
OGCGeometry
.fromGeoJson(
"{\"type\": \"LineString\", \"coordinates\": [[2.449,4.865], [7.00000001,8.00000001]]}")
.intersects(g2);
OGCGeometry g3 = OGCGeometry.fromGeoJson(
"{\"type\": \"Polygon\", \"coordinates\": [[[1.00000001,1.00000001], [4.00000001,1.00000001], [4.00000001,4.00000001], [1.00000001,4.00000001]]]}");
boolean bb = g2.equals((Object) g3);
assertTrue(bb);
}
}
示例3: testGeometryCollection
import com.esri.core.geometry.ogc.OGCGeometry; //导入方法依赖的package包/类
@Test
public void testGeometryCollection() throws Exception {
OGCGeometry g = OGCGeometry
.fromText("GEOMETRYCOLLECTION(POLYGON EMPTY, POINT(1 1), LINESTRING EMPTY, MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)");
assertTrue(g.geometryType().equals("GeometryCollection"));
OGCConcreteGeometryCollection gc = (OGCConcreteGeometryCollection) g;
assertTrue(gc.numGeometries() == 5);
assertTrue(gc.geometryN(0).geometryType().equals("Polygon"));
assertTrue(gc.geometryN(1).geometryType().equals("Point"));
assertTrue(gc.geometryN(2).geometryType().equals("LineString"));
assertTrue(gc.geometryN(3).geometryType().equals("MultiPolygon"));
assertTrue(gc.geometryN(4).geometryType().equals("MultiLineString"));
g = OGCGeometry
.fromText("GEOMETRYCOLLECTION(POLYGON EMPTY, POINT(1 1), GEOMETRYCOLLECTION EMPTY, LINESTRING EMPTY, GEOMETRYCOLLECTION(POLYGON EMPTY, POINT(1 1), LINESTRING EMPTY, MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY, MULTIPOINT EMPTY), MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)");
assertTrue(g.geometryType().equals("GeometryCollection"));
gc = (OGCConcreteGeometryCollection) g;
assertTrue(gc.numGeometries() == 7);
assertTrue(gc.geometryN(0).geometryType().equals("Polygon"));
assertTrue(gc.geometryN(1).geometryType().equals("Point"));
assertTrue(gc.geometryN(2).geometryType().equals("GeometryCollection"));
assertTrue(gc.geometryN(3).geometryType().equals("LineString"));
assertTrue(gc.geometryN(4).geometryType().equals("GeometryCollection"));
assertTrue(gc.geometryN(5).geometryType().equals("MultiPolygon"));
assertTrue(gc.geometryN(6).geometryType().equals("MultiLineString"));
OGCConcreteGeometryCollection gc2 = (OGCConcreteGeometryCollection) gc
.geometryN(4);
assertTrue(gc2.numGeometries() == 6);
assertTrue(gc2.geometryN(0).geometryType().equals("Polygon"));
assertTrue(gc2.geometryN(1).geometryType().equals("Point"));
assertTrue(gc2.geometryN(2).geometryType().equals("LineString"));
assertTrue(gc2.geometryN(3).geometryType().equals("MultiPolygon"));
assertTrue(gc2.geometryN(4).geometryType().equals("MultiLineString"));
assertTrue(gc2.geometryN(5).geometryType().equals("MultiPoint"));
ByteBuffer wkbBuffer = g.asBinary();
g = OGCGeometry.fromBinary(wkbBuffer);
assertTrue(g.geometryType().equals("GeometryCollection"));
gc = (OGCConcreteGeometryCollection) g;
assertTrue(gc.numGeometries() == 7);
assertTrue(gc.geometryN(0).geometryType().equals("Polygon"));
assertTrue(gc.geometryN(1).geometryType().equals("Point"));
assertTrue(gc.geometryN(2).geometryType().equals("GeometryCollection"));
assertTrue(gc.geometryN(3).geometryType().equals("LineString"));
assertTrue(gc.geometryN(4).geometryType().equals("GeometryCollection"));
assertTrue(gc.geometryN(5).geometryType().equals("MultiPolygon"));
assertTrue(gc.geometryN(6).geometryType().equals("MultiLineString"));
gc2 = (OGCConcreteGeometryCollection) gc.geometryN(4);
assertTrue(gc2.numGeometries() == 6);
assertTrue(gc2.geometryN(0).geometryType().equals("Polygon"));
assertTrue(gc2.geometryN(1).geometryType().equals("Point"));
assertTrue(gc2.geometryN(2).geometryType().equals("LineString"));
assertTrue(gc2.geometryN(3).geometryType().equals("MultiPolygon"));
assertTrue(gc2.geometryN(4).geometryType().equals("MultiLineString"));
assertTrue(gc2.geometryN(5).geometryType().equals("MultiPoint"));
String wktString = g.asText();
assertTrue(wktString
.equals("GEOMETRYCOLLECTION (POLYGON EMPTY, POINT (1 1), GEOMETRYCOLLECTION EMPTY, LINESTRING EMPTY, GEOMETRYCOLLECTION (POLYGON EMPTY, POINT (1 1), LINESTRING EMPTY, MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY, MULTIPOINT EMPTY), MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)"));
g = OGCGeometry
.fromGeoJson("{\"type\" : \"GeometryCollection\", \"geometries\" : [{\"type\" : \"Polygon\", \"coordinates\" : []}, {\"type\" : \"Point\", \"coordinates\" : [1, 1]}, {\"type\" : \"GeometryCollection\", \"geometries\" : []}, {\"type\" : \"LineString\", \"coordinates\" : []}, {\"type\" : \"GeometryCollection\", \"geometries\" : [{\"type\": \"Polygon\", \"coordinates\" : []}, {\"type\" : \"Point\", \"coordinates\" : [1,1]}, {\"type\" : \"LineString\", \"coordinates\" : []}, {\"type\" : \"MultiPolygon\", \"coordinates\" : []}, {\"type\" : \"MultiLineString\", \"coordinates\" : []}, {\"type\" : \"MultiPoint\", \"coordinates\" : []}]}, {\"type\" : \"MultiPolygon\", \"coordinates\" : []}, {\"type\" : \"MultiLineString\", \"coordinates\" : []} ] }");
wktString = g.asText();
assertTrue(wktString
.equals("GEOMETRYCOLLECTION (POLYGON EMPTY, POINT (1 1), GEOMETRYCOLLECTION EMPTY, LINESTRING EMPTY, GEOMETRYCOLLECTION (POLYGON EMPTY, POINT (1 1), LINESTRING EMPTY, MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY, MULTIPOINT EMPTY), MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)"));
assertTrue(g.equals((Object)OGCGeometry.fromText(wktString)));
assertTrue(g.hashCode() == OGCGeometry.fromText(wktString).hashCode());
}