Java Code Examples for com.esri.core.geometry.ogc.OGCGeometry#buffer()

The following examples show how to use com.esri.core.geometry.ogc.OGCGeometry#buffer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoUtils.java    From HolandaCatalinaFw with Apache License 2.0 6 votes vote down vote up
private static OGCGeometry fromGeoJson(Map<String,Object> geoJson) {
   OGCGeometry result = null;
   if(geoJson.containsKey(Paths.COORDINATES)) {
       result = OGCGeometry.fromGeoJson(JsonUtils.toJsonTree(geoJson).toString());
   } else {
       Collection<Map<String, Object>> features = Introspection.resolve(geoJson, Paths.FEATURES);
       OGCGeometry geometry;
       for (Map<String, Object> feature : features) {
           Number buffer = Introspection.resolve(feature, Paths.PROPERTIES_RADIUS);
           if (buffer == null) {
               buffer = Introspection.resolve(feature, Paths.PROPERTIES_BUFFER);
           }
           geometry = OGCGeometry.fromGeoJson(JsonUtils.toJsonTree(Introspection.resolve(feature, Paths.GEOMETRY)).toString());
           if (buffer != null) {
               geometry = geometry.buffer(buffer.doubleValue());
           }
           if (result == null) {
               result = geometry;
           } else {
               result.union(geometry);
           }
       }
   }
   return result;
}
 
Example 2
Source File: ST_Buffer.java    From spatial-framework-for-hadoop with Apache License 2.0 6 votes vote down vote up
public BytesWritable evaluate(BytesWritable geometryref1, DoubleWritable distance)
{
	if (geometryref1 == null || geometryref1.getLength() == 0 || distance == null) {
		return null;
	}

	OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geometryref1);
	if (ogcGeometry == null){
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}

	OGCGeometry bufferedGeometry = ogcGeometry.buffer(distance.get());
	// TODO persist type information (polygon vs multipolygon)
	return GeometryUtils.geometryToEsriShapeBytesWritable(bufferedGeometry);
}
 
Example 3
Source File: TestOGC.java    From geometry-api-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testPoint() {
	OGCGeometry g = OGCGeometry.fromText("POINT(1 2)");
	assertTrue(g.geometryType().equals("Point"));
	OGCPoint p = (OGCPoint) g;
	assertTrue(p.X() == 1);
	assertTrue(p.Y() == 2);
	assertTrue(g.equals(OGCGeometry.fromText("POINT(1 2)")));
	assertTrue(!g.equals(OGCGeometry.fromText("POINT(1 3)")));
	assertTrue(g.equals((Object)OGCGeometry.fromText("POINT(1 2)")));
	assertTrue(!g.equals((Object)OGCGeometry.fromText("POINT(1 3)")));
	OGCGeometry buf = g.buffer(10);
	assertTrue(buf.geometryType().equals("Polygon"));
	OGCPolygon poly = (OGCPolygon) buf.envelope();
	double a = poly.area();
	assertTrue(Math.abs(a - 400) < 1e-1);
}
 
Example 4
Source File: TestBuffer.java    From geometry-api-java with Apache License 2.0 6 votes vote down vote up
@Test
public static void testTinyBufferOfPoint() {
	{
		Geometry result1 = OperatorBuffer.local().execute(new Point(0, 0), SpatialReference.create(4326), 1e-9, null);
		assertTrue(result1 != null);
		assertTrue(result1.isEmpty());
		Geometry geom1 = OperatorImportFromWkt.local().execute(0, Geometry.Type.Unknown, "POLYGON ((177.0 64.0, 177.0000000001 64.0, 177.0000000001 64.0000000001, 177.0 64.0000000001, 177.0 64.0))", null);
		Geometry result2 = OperatorBuffer.local().execute(geom1, SpatialReference.create(4326), 0.01, null);
		assertTrue(result2 != null);
		assertTrue(result2.isEmpty());
		
	}
	
	{
		OGCGeometry p = OGCGeometry.fromText(
				"POLYGON ((177.0 64.0, 177.0000000001 64.0, 177.0000000001 64.0000000001, 177.0 64.0000000001, 177.0 64.0))");
		OGCGeometry buffered = p.buffer(0.01);
		assertTrue(buffered != null);
	}
	
	
}
 
Example 5
Source File: TestOGC.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testGeometryCollectionBuffer() {
	OGCGeometry g = OGCGeometry
			.fromText("GEOMETRYCOLLECTION(POINT(1 1), POINT(1 1), POINT(1 2), LINESTRING (0 0, 1 1, 1 0, 0 1), MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)");
	OGCGeometry simpleG = g.buffer(0);
	String t = simpleG.geometryType();
	String rt = simpleG.asText();
	assertTrue(simpleG.geometryType().equals("GeometryCollection"));
}