Java Code Examples for com.esri.core.geometry.Geometry#Type

The following examples show how to use com.esri.core.geometry.Geometry#Type . 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: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
private static String _parseGeometryType(Geometry.Type t)
{
	String type = null;
	if(t == Geometry.Type.Point)
	{
		type = "esriGeometryPoint";
	}
	else if (t==Geometry.Type.Polyline)
	{
		type = "esriGeometryPolyline";
	}
	else if (t==Geometry.Type.Polygon)
	{
		type = "esriGeometryPolygon";
	}
	else if (t==Geometry.Type.MultiPoint)
	{
		type = "esriGeometryMultiPoint";
	}
	return type;
}
 
Example 2
Source File: GeometryTypeJsonDeserializer.java    From spatial-framework-for-hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public Geometry.Type deserialize(JsonParser parser, DeserializationContext arg1)
		throws IOException, JsonProcessingException {
	
	String type_text = parser.getText();
	
	// geometry type enumerations coming from the JSON are prepended with "esriGeometry" (i.e. esriGeometryPolygon)
	// while the geometry-java-api uses the form Geometry.Type.Polygon
	if (type_text.startsWith("esriGeometry"))
	{
		// cut out esriGeometry to match Geometry.Type enumeration values
		type_text = type_text.substring(12);
		
		try {
			return Enum.valueOf(Geometry.Type.class, type_text);
		} catch (Exception e){
			// parsing failed, fall through to unknown geometry type
		}
	}
	
	
	return Geometry.Type.Unknown;
}
 
Example 3
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
private static String _parseGeometryType(Geometry.Type t)
{
	String type = null;
	if(t == Geometry.Type.Point)
	{
		type = "esriGeometryPoint";
	}
	else if (t==Geometry.Type.Polyline)
	{
		type = "esriGeometryPolyline";
	}
	else if (t==Geometry.Type.Polygon)
	{
		type = "esriGeometryPolygon";
	}
	else if (t==Geometry.Type.MultiPoint)
	{
		type = "esriGeometryMultiPoint";
	}
	return type;
}
 
Example 4
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
private static String _parseGeometryType(Geometry.Type t)
{
	String type = null;
	if(t == Geometry.Type.Point)
	{
		type = "esriGeometryPoint";
	}
	else if (t==Geometry.Type.Polyline)
	{
		type = "esriGeometryPolyline";
	}
	else if (t==Geometry.Type.Polygon)
	{
		type = "esriGeometryPolygon";
	}
	else if (t==Geometry.Type.MultiPoint)
	{
		type = "esriGeometryMultiPoint";
	}
	return type;
}
 
Example 5
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
private static String _parseGeometryType(Geometry.Type t)
{
	String type = null;
	if(t == Geometry.Type.Point)
	{
		type = "esriGeometryPoint";
	}
	else if (t==Geometry.Type.Polyline)
	{
		type = "esriGeometryPolyline";
	}
	else if (t==Geometry.Type.Polygon)
	{
		type = "esriGeometryPolygon";
	}
	else if (t==Geometry.Type.MultiPoint)
	{
		type = "esriGeometryMultiPoint";
	}
	return type;
}
 
Example 6
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
private static String _parseGeometryType(Geometry.Type t)
{
	String type = null;
	if(t == Geometry.Type.Point)
	{
		type = "esriGeometryPoint";
	}
	else if (t==Geometry.Type.Polyline)
	{
		type = "esriGeometryPolyline";
	}
	else if (t==Geometry.Type.Polygon)
	{
		type = "esriGeometryPolygon";
	}
	else if (t==Geometry.Type.MultiPoint)
	{
		type = "esriGeometryMultiPoint";
	}
	return type;
}
 
Example 7
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
private static String _parseGeometryType(Geometry.Type t)
{
	String type = null;
	if(t == Geometry.Type.Point)
	{
		type = "esriGeometryPoint";
	}
	else if (t==Geometry.Type.Polyline)
	{
		type = "esriGeometryPolyline";
	}
	else if (t==Geometry.Type.Polygon)
	{
		type = "esriGeometryPolygon";
	}
	else if (t==Geometry.Type.MultiPoint)
	{
		type = "esriGeometryMultiPoint";
	}
	return type;
}
 
Example 8
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
private static String _parseGeometryType(Geometry.Type t)
{
	String type = null;
	if(t == Geometry.Type.Point)
	{
		type = "esriGeometryPoint";
	}
	else if (t==Geometry.Type.Polyline)
	{
		type = "esriGeometryPolyline";
	}
	else if (t==Geometry.Type.Polygon)
	{
		type = "esriGeometryPolygon";
	}
	else if (t==Geometry.Type.MultiPoint)
	{
		type = "esriGeometryMultiPoint";
	}
	return type;
}
 
Example 9
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
private static String _parseGeometryType(Geometry.Type t)
{
	String type = null;
	if(t == Geometry.Type.Point)
	{
		type = "esriGeometryPoint";
	}
	else if (t==Geometry.Type.Polyline)
	{
		type = "esriGeometryPolyline";
	}
	else if (t==Geometry.Type.Polygon)
	{
		type = "esriGeometryPolygon";
	}
	else if (t==Geometry.Type.MultiPoint)
	{
		type = "esriGeometryMultiPoint";
	}
	return type;
}
 
Example 10
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
private static String _parseGeometryType(Geometry.Type t)
{
	String type = null;
	if(t == Geometry.Type.Point)
	{
		type = "esriGeometryPoint";
	}
	else if (t==Geometry.Type.Polyline)
	{
		type = "esriGeometryPolyline";
	}
	else if (t==Geometry.Type.Polygon)
	{
		type = "esriGeometryPolygon";
	}
	else if (t==Geometry.Type.MultiPoint)
	{
		type = "esriGeometryMultiPoint";
	}
	return type;
}
 
Example 11
Source File: GeometrySerde.java    From presto with Apache License 2.0 5 votes vote down vote up
private static OGCGeometry createFromEsriGeometry(Geometry geometry, boolean multiType)
{
    Geometry.Type type = geometry.getType();
    switch (type) {
        case Polygon: {
            if (!multiType && ((Polygon) geometry).getExteriorRingCount() <= 1) {
                return new OGCPolygon((Polygon) geometry, null);
            }
            return new OGCMultiPolygon((Polygon) geometry, null);
        }
        case Polyline: {
            if (!multiType && ((Polyline) geometry).getPathCount() <= 1) {
                return new OGCLineString((Polyline) geometry, 0, null);
            }
            return new OGCMultiLineString((Polyline) geometry, null);
        }
        case MultiPoint: {
            if (!multiType && ((MultiPoint) geometry).getPointCount() <= 1) {
                if (geometry.isEmpty()) {
                    return new OGCPoint(new Point(), null);
                }
                return new OGCPoint(((MultiPoint) geometry).getPoint(0), null);
            }
            return new OGCMultiPoint((MultiPoint) geometry, null);
        }
        case Point: {
            if (!multiType) {
                return new OGCPoint((Point) geometry, null);
            }
            return new OGCMultiPoint((Point) geometry, null);
        }
        case Envelope: {
            Polygon polygon = new Polygon();
            polygon.addEnvelope((Envelope) geometry, false);
            return new OGCPolygon(polygon, null);
        }
        default:
            throw new IllegalArgumentException("Unexpected geometry type: " + type);
    }
}
 
Example 12
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 4 votes vote down vote up
public static String parseGeometryType(Geometry.Type t)
{
	return _parseGeometryType(t);
}
 
Example 13
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 4 votes vote down vote up
public static String parseGeometryType(Geometry.Type t)
{
	return _parseGeometryType(t);
}
 
Example 14
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 4 votes vote down vote up
public static String parseGeometryType(Geometry.Type t)
{
	return _parseGeometryType(t);
}
 
Example 15
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 4 votes vote down vote up
public static String parseGeometryType(Geometry.Type t)
{
	return _parseGeometryType(t);
}
 
Example 16
Source File: OGCGeometry.java    From geometry-api-java with Apache License 2.0 4 votes vote down vote up
public static OGCGeometry createFromEsriGeometry(Geometry geom,
		SpatialReference sr, boolean multiType) {
	if (geom == null)
		return null;
	Geometry.Type t = geom.getType();
	if (t == Geometry.Type.Polygon) {
		if (!multiType && ((Polygon) geom).getExteriorRingCount() == 1)
			return new OGCPolygon((Polygon) geom, sr);
		else
			return new OGCMultiPolygon((Polygon) geom, sr);
	}
	if (t == Geometry.Type.Polyline) {
		if (!multiType && ((Polyline) geom).getPathCount() == 1)
			return new OGCLineString((Polyline) geom, 0, sr);
		else
			return new OGCMultiLineString((Polyline) geom, sr);
	}
	if (t == Geometry.Type.MultiPoint) {
		if (!multiType && ((MultiPoint) geom).getPointCount() <= 1) {
			if (geom.isEmpty())
				return new OGCPoint(new Point(), sr);
			else
				return new OGCPoint(((MultiPoint) geom).getPoint(0), sr);
		} else
			return new OGCMultiPoint((MultiPoint) geom, sr);
	}
	if (t == Geometry.Type.Point) {
		if (!multiType) {
			return new OGCPoint((Point) geom, sr);
		} else {
			return new OGCMultiPoint((Point) geom, sr);
		}
	}
	if (t == Geometry.Type.Envelope) {
		Polygon p = new Polygon();
		p.addEnvelope((Envelope) geom, false);
		return createFromEsriGeometry(p, sr, multiType);
	}

	throw new UnsupportedOperationException();
}
 
Example 17
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 4 votes vote down vote up
public static String parseGeometryType(Geometry.Type t)
{
	return _parseGeometryType(t);
}
 
Example 18
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 4 votes vote down vote up
public static String parseGeometryType(Geometry.Type t)
{
	return _parseGeometryType(t);
}
 
Example 19
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 4 votes vote down vote up
public static String parseGeometryType(Geometry.Type t)
{
	return _parseGeometryType(t);
}
 
Example 20
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 4 votes vote down vote up
public static String parseGeometryType(Geometry.Type t)
{
	return _parseGeometryType(t);
}