com.esri.core.geometry.Operator Java Examples

The following examples show how to use com.esri.core.geometry.Operator. 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: OGCGeometry.java    From geometry-api-java with Apache License 2.0 6 votes vote down vote up
public OGCGeometry union(OGCGeometry another) {
	String thisType = geometryType();
	String anotherType = another.geometryType();
	if (thisType != anotherType || thisType == OGCConcreteGeometryCollection.TYPE) {
		//heterogeneous union.
		//We make a geometry collection, then process to union parts and remove overlaps.
		ArrayList<OGCGeometry> geoms = new ArrayList<OGCGeometry>();
		geoms.add(this);
		geoms.add(another);
		OGCConcreteGeometryCollection geomCol = new OGCConcreteGeometryCollection(geoms, esriSR);
		return geomCol.flattenAndRemoveOverlaps().reduceFromMulti();
	}
	
	OperatorUnion op = (OperatorUnion) OperatorFactoryLocal.getInstance()
			.getOperator(Operator.Type.Union);
	GeometryCursorAppend ap = new GeometryCursorAppend(
			getEsriGeometryCursor(), another.getEsriGeometryCursor());
	com.esri.core.geometry.GeometryCursor cursor = op.execute(ap,
			getEsriSpatialReference(), null);
	return OGCGeometry.createFromEsriCursor(cursor, esriSR);
}
 
Example #2
Source File: OGCMultiPoint.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
@Override
public ByteBuffer asBinary() {
	OperatorExportToWkb op = (OperatorExportToWkb) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.ExportToWkb);
	return op.execute(WkbExportFlags.wkbExportMultiPoint,
			getEsriGeometry(), null);
}
 
Example #3
Source File: OGCLineString.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
@Override
public ByteBuffer asBinary() {
	OperatorExportToWkb op = (OperatorExportToWkb) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.ExportToWkb);
	return op.execute(WkbExportFlags.wkbExportLineString,
			getEsriGeometry(), null);
}
 
Example #4
Source File: OGCGeometry.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
public static OGCGeometry fromGeoJson(String string) {
	OperatorImportFromGeoJson op = (OperatorImportFromGeoJson) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.ImportFromGeoJson);
	MapOGCStructure mapOGCStructure = op.executeOGC(0, string, null);
	return OGCGeometry.createFromOGCStructure(
			mapOGCStructure.m_ogcStructure,
			mapOGCStructure.m_spatialReference);
}
 
Example #5
Source File: OGCGeometry.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
public static OGCGeometry fromEsriShape(ByteBuffer buffer) {
	OperatorImportFromESRIShape op = (OperatorImportFromESRIShape) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.ImportFromESRIShape);
	Geometry g = op.execute(0, Geometry.Type.Unknown, buffer);
	return OGCGeometry.createFromEsriGeometry(g,
			SpatialReference.create(4326));
}
 
Example #6
Source File: OGCGeometry.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
public static OGCGeometry fromBinary(ByteBuffer binary) {
	OperatorImportFromWkb op = (OperatorImportFromWkb) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.ImportFromWkb);
	OGCStructure ogcStructure = op.executeOGC(0, binary, null);
	return OGCGeometry.createFromOGCStructure(ogcStructure,
			SpatialReference.create(4326));
}
 
Example #7
Source File: OGCGeometry.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
public static OGCGeometry fromText(String text) {
	OperatorImportFromWkt op = (OperatorImportFromWkt) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.ImportFromWkt);
	OGCStructure ogcStructure = op.executeOGC(0, text, null);
	return OGCGeometry.createFromOGCStructure(ogcStructure,
			SpatialReference.create(4326));
}
 
Example #8
Source File: OGCGeometry.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
public OGCGeometry intersection(OGCGeometry another) {
	if (another.geometryType() == OGCConcreteGeometryCollection.TYPE) {
		return (new OGCConcreteGeometryCollection(this, esriSR)).intersection(another);
	}

	com.esri.core.geometry.OperatorIntersection op = (OperatorIntersection) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.Intersection);
	com.esri.core.geometry.GeometryCursor cursor = op.execute(
			getEsriGeometryCursor(), another.getEsriGeometryCursor(),
			getEsriSpatialReference(), null, 7);
	return OGCGeometry.createFromEsriCursor(cursor, esriSR, true);
}
 
Example #9
Source File: OGCGeometry.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
public OGCGeometry buffer(double distance) {
	OperatorBuffer op = (OperatorBuffer) OperatorFactoryLocal.getInstance()
			.getOperator(Operator.Type.Buffer);
	if (distance == 0) {// when distance is 0, return self (maybe we should
						// create a copy instead).
		return this;
	}

	double d[] = { distance };
	com.esri.core.geometry.GeometryCursor cursor = op.execute(
			getEsriGeometryCursor(), getEsriSpatialReference(), d, true,
			null);
	return OGCGeometry.createFromEsriGeometry(cursor.next(), esriSR);
}
 
Example #10
Source File: OGCGeometry.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
/**
 * Makes a simple geometry for Geodatabase.
 * 
 * @return Returns simplified geometry.
 * 
 * Note: isSimpleRelaxed should return true after this operation.
 */
public OGCGeometry makeSimpleRelaxed(boolean forceProcessing) {
	OperatorSimplify op = (OperatorSimplify) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.Simplify);
	return OGCGeometry.createFromEsriGeometry(
			op.execute(getEsriGeometry(), esriSR, forceProcessing, null),
			esriSR);
}
 
Example #11
Source File: OGCPoint.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
@Override
public ByteBuffer asBinary() {
	OperatorExportToWkb op = (OperatorExportToWkb) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.ExportToWkb);
	return op.execute(WkbExportFlags.wkbExportPoint, getEsriGeometry(),
			null);
}
 
Example #12
Source File: OGCMultiLineString.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
@Override
public OGCGeometry boundary() {
	OperatorBoundary op = (OperatorBoundary) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.Boundary);
	Geometry g = op.execute(polyline, null);
	return OGCGeometry.createFromEsriGeometry(g, esriSR, true);
}
 
Example #13
Source File: OGCMultiLineString.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
@Override
public ByteBuffer asBinary() {
	OperatorExportToWkb op = (OperatorExportToWkb) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.ExportToWkb);
	return op.execute(WkbExportFlags.wkbExportMultiLineString,
			getEsriGeometry(), null);
}
 
Example #14
Source File: PagesSpatialIndexSupplier.java    From presto with Apache License 2.0 5 votes vote down vote up
private static void accelerateGeometry(OGCGeometry ogcGeometry, Operator relateOperator)
{
    // Recurse into GeometryCollections
    GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor();
    while (true) {
        com.esri.core.geometry.Geometry esriGeometry = cursor.next();
        if (esriGeometry == null) {
            break;
        }
        relateOperator.accelerateGeometry(esriGeometry, null, Geometry.GeometryAccelerationDegree.enumMild);
    }
}
 
Example #15
Source File: OGCMultiPolygon.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
@Override
public ByteBuffer asBinary() {
	OperatorExportToWkb op = (OperatorExportToWkb) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.ExportToWkb);
	return op.execute(WkbExportFlags.wkbExportMultiPolygon,
			getEsriGeometry(), null);
}
 
Example #16
Source File: UserDefinedGeoJsonSpatialFilter.java    From bboxdb with Apache License 2.0 5 votes vote down vote up
/**
 * Convert the geojson element to a ESRI geometry
 * @param jsonString
 * @return
 */
private OGCGeometry geoJoinToGeomety(String jsonString) {
	final OperatorImportFromGeoJson op = (OperatorImportFromGeoJson) OperatorFactoryLocal
	        .getInstance().getOperator(Operator.Type.ImportFromGeoJson);
			
    final MapOGCStructure structure = op.executeOGC(WktImportFlags.wktImportDefaults, jsonString, null);

    return OGCGeometry.createFromOGCStructure(structure.m_ogcStructure,
    		structure.m_spatialReference);
}
 
Example #17
Source File: OGCPolygon.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
@Override
public ByteBuffer asBinary() {
	OperatorExportToWkb op = (OperatorExportToWkb) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.ExportToWkb);
	return op.execute(WkbExportFlags.wkbExportPolygon, getEsriGeometry(),
			null);
}
 
Example #18
Source File: PagesSpatialIndexSupplier.java    From presto with Apache License 2.0 4 votes vote down vote up
private static STRtree buildRTree(LongArrayList addresses, List<List<Block>> channels, int geometryChannel, Optional<Integer> radiusChannel, Optional<Integer> partitionChannel)
{
    STRtree rtree = new STRtree();
    Operator relateOperator = OperatorFactoryLocal.getInstance().getOperator(Operator.Type.Relate);

    for (int position = 0; position < addresses.size(); position++) {
        long pageAddress = addresses.getLong(position);
        int blockIndex = decodeSliceIndex(pageAddress);
        int blockPosition = decodePosition(pageAddress);

        Block block = channels.get(geometryChannel).get(blockIndex);
        // TODO Consider pushing is-null and is-empty checks into a filter below the join
        if (block.isNull(blockPosition)) {
            continue;
        }

        Slice slice = block.getSlice(blockPosition, 0, block.getSliceLength(blockPosition));
        OGCGeometry ogcGeometry = deserialize(slice);
        verifyNotNull(ogcGeometry);
        if (ogcGeometry.isEmpty()) {
            continue;
        }

        double radius = radiusChannel.map(channel -> DOUBLE.getDouble(channels.get(channel).get(blockIndex), blockPosition)).orElse(0.0);
        if (radius < 0) {
            continue;
        }

        if (radiusChannel.isEmpty()) {
            // If radiusChannel is supplied, this is a distance query, for which our acceleration won't help.
            accelerateGeometry(ogcGeometry, relateOperator);
        }

        int partition = -1;
        if (partitionChannel.isPresent()) {
            Block partitionBlock = channels.get(partitionChannel.get()).get(blockIndex);
            partition = toIntExact(INTEGER.getLong(partitionBlock, blockPosition));
        }

        rtree.insert(getEnvelope(ogcGeometry, radius), new GeometryWithPosition(ogcGeometry, partition, position));
    }

    rtree.build();
    return rtree;
}
 
Example #19
Source File: OGCMultiLineString.java    From geometry-api-java with Apache License 2.0 4 votes vote down vote up
@Override
public String asGeoJson() {
	OperatorExportToGeoJson op = (OperatorExportToGeoJson) OperatorFactoryLocal.getInstance()
			.getOperator(Operator.Type.ExportToGeoJson);
	return op.execute(GeoJsonExportFlags.geoJsonExportPreferMultiGeometry, null, getEsriGeometry());
}
 
Example #20
Source File: GeoFunctions.java    From Quicksql with MIT License 4 votes vote down vote up
private static boolean intersects(Geometry g1, Geometry g2,
    SpatialReference sr) {
  final OperatorIntersects op = (OperatorIntersects) OperatorFactoryLocal
      .getInstance().getOperator(Operator.Type.Intersects);
  return op.execute(g1, g2, sr, null);
}
 
Example #21
Source File: Criteria.java    From geoportal-server-harvester with Apache License 2.0 4 votes vote down vote up
@Override
public Operator.Type getOperation() {
  return operation;
}
 
Example #22
Source File: GeoFunctions.java    From calcite with Apache License 2.0 4 votes vote down vote up
private static boolean intersects(Geometry g1, Geometry g2,
    SpatialReference sr) {
  final OperatorIntersects op = (OperatorIntersects) OperatorFactoryLocal
      .getInstance().getOperator(Operator.Type.Intersects);
  return op.execute(g1, g2, sr, null);
}
 
Example #23
Source File: OGCGeometry.java    From geometry-api-java with Apache License 2.0 4 votes vote down vote up
String asGeoJsonImpl(int export_flags) {
	OperatorExportToGeoJson op = (OperatorExportToGeoJson) OperatorFactoryLocal.getInstance().getOperator(Operator.Type.ExportToGeoJson);
	return op.execute(export_flags, esriSR, getEsriGeometry());
}
 
Example #24
Source File: OGCGeometry.java    From geometry-api-java with Apache License 2.0 4 votes vote down vote up
public String asGeoJson() {
	OperatorExportToGeoJson op = (OperatorExportToGeoJson) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.ExportToGeoJson);
	return op.execute(esriSR, getEsriGeometry());
}
 
Example #25
Source File: OGCGeometry.java    From geometry-api-java with Apache License 2.0 4 votes vote down vote up
public ByteBuffer asBinary() {
	OperatorExportToWkb op = (OperatorExportToWkb) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.ExportToWkb);
	return op.execute(0, getEsriGeometry(), null);
}
 
Example #26
Source File: GeoFunctions.java    From Bats with Apache License 2.0 4 votes vote down vote up
private static boolean intersects(Geometry g1, Geometry g2,
    SpatialReference sr) {
  final OperatorIntersects op = (OperatorIntersects) OperatorFactoryLocal
      .getInstance().getOperator(Operator.Type.Intersects);
  return op.execute(g1, g2, sr, null);
}
 
Example #27
Source File: OGCMultiPolygon.java    From geometry-api-java with Apache License 2.0 4 votes vote down vote up
@Override
public String asGeoJson() {
    OperatorExportToGeoJson op = (OperatorExportToGeoJson) OperatorFactoryLocal
            .getInstance().getOperator(Operator.Type.ExportToGeoJson);
    return op.execute(GeoJsonExportFlags.geoJsonExportPreferMultiGeometry, null, getEsriGeometry());
}
 
Example #28
Source File: OGCGeometry.java    From geometry-api-java with Apache License 2.0 2 votes vote down vote up
/**
 * Extension method - checks if geometry is simple for Geodatabase.
 * 
 * @return Returns true if geometry is simple, false otherwise.
 * 
 * Note: If isSimpleRelaxed is true, then isSimple is either true or false. Geodatabase has more relaxed requirements for simple geometries than OGC.
 */
public boolean isSimpleRelaxed() {
	OperatorSimplify op = (OperatorSimplify) OperatorFactoryLocal
			.getInstance().getOperator(Operator.Type.Simplify);
	return op.isSimpleAsFeature(getEsriGeometry(), esriSR, true, null, null);
}
 
Example #29
Source File: Criteria.java    From geoportal-server-harvester with Apache License 2.0 2 votes vote down vote up
/**
 * Sets operation type.
 * @param operation operation type
 */
public void setOperation(Operator.Type operation) {
  this.operation = operation;
}
 
Example #30
Source File: ICriteria.java    From geoportal-server-harvester with Apache License 2.0 2 votes vote down vote up
/**
 * Gets spatial operation type.
 * @return spatial operation type
 */
Operator.Type getOperation();