com.esri.core.geometry.Point Java Examples

The following examples show how to use com.esri.core.geometry.Point. 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: EnvelopeOperationTest.java    From sis with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a feature type with a bounds operation.
 * The feature contains the following properties:
 *
 * <ul>
 *   <li>{@code name} as a {@link String}</li>
 *   <li>{@code classes} as a {@link Polygon}</li>
 *   <li>{@code climbing wall} as a {@link Point}</li>
 *   <li>{@code gymnasium} as a {@link Polygon}</li>
 *   <li>{@code sis:geometry} as a link to the default geometry</li>
 *   <li>{@code bounds} as the feature envelope attribute.</li>
 * </ul>
 *
 * @param  defaultGeometry  1 for using "classes" as the default geometry, or 3 for "gymnasium".
 * @return the feature for a school.
 */
private static DefaultFeatureType school(final int defaultGeometry) throws FactoryException {
    final DefaultAttributeType<?> standardCRS = new DefaultAttributeType<>(
            name(AttributeConvention.CRS_CHARACTERISTIC), CoordinateReferenceSystem.class, 1, 1, HardCodedCRS.WGS84_φλ);

    final DefaultAttributeType<?> normalizedCRS = new DefaultAttributeType<>(
            name(AttributeConvention.CRS_CHARACTERISTIC), CoordinateReferenceSystem.class, 1, 1, HardCodedCRS.WGS84);

    final AbstractIdentifiedType[] attributes = {
        new DefaultAttributeType<>(name("name"),          String.class,  1, 1, null),
        new DefaultAttributeType<>(name("classes"),       Polygon.class, 1, 1, null, standardCRS),
        new DefaultAttributeType<>(name("climbing wall"), Point.class,   1, 1, null, standardCRS),
        new DefaultAttributeType<>(name("gymnasium"),     Polygon.class, 1, 1, null, normalizedCRS),
        null,
        null
    };
    attributes[4] = FeatureOperations.link(name(AttributeConvention.GEOMETRY_PROPERTY), attributes[defaultGeometry]);
    attributes[5] = FeatureOperations.envelope(name("bounds"), null, attributes);
    return new DefaultFeatureType(name("school"), false, null, attributes);
}
 
Example #3
Source File: GeoJsonParser.java    From arcgis-runtime-demo-java with Apache License 2.0 6 votes vote down vote up
/**
 * Example:
 * [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
 * @param parser
 * @return a polygon
 * @throws JsonParseException
 * @throws IOException
 */
private Polygon parseSimplePolygonCoordinates(JsonNode node) {
  Polygon g = new Polygon();
  boolean first = true;
  ArrayNode points = (ArrayNode) node;
  for (JsonNode point : points) {
    Point p = parsePointCoordinates(point);
    if (first) {
      g.startPath(p);
      first = false;
    } else {
      g.lineTo(p);
    }  
  }
  g.closeAllPaths();
  return g;
}
 
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: GeofenceServiceNormal.java    From arcgis-runtime-demos-android with Apache License 2.0 6 votes vote down vote up
/**
 * This action is handled in the provided background thread. It is called
 * when this service receives a location update from Google fusion API;
 * therefore no connection to the Google API client is required.
 */
private void handleActionCheckLocation(Location newLocation) {

  if(newLocation !=null) {
    // The incoming location is the current device location, in geographic coordinates.
    Point locationPoint = new Point(newLocation.getLongitude(), newLocation.getLatitude());
    LocalGeofence.FenceInformation info = LocalGeofence.latestLocation(locationPoint);
    Log.i(TAG, String.format("GeofenceServiceNormal Status: %s, UpdateChange: %s, Change: %s", info.status, info.updateChange, info.change));

    if (info.change == LocalGeofence.Change.ENTERED) {
      sendNotification(String.format("Alert! Entered %s", LocalGeofence.getFeatureName()));
    }
    else if (info.change == LocalGeofence.Change.EXITED) {
      sendNotification(String.format("Exited %s", LocalGeofence.getFeatureName()));
    }

    if (LocalGeofence.UpdateChange.FASTER == info.updateChange) {
      // Ensure we are receiving updates frequently.
      handleActionChangeToFastUpdates();
    }
    else if (LocalGeofence.UpdateChange.SLOWER == info.updateChange) {
      // Ensure we are receiving updates less frequently.
      handleActionStartNormalUpdates();
    }
  }
}
 
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: GeoFunctions.java    From Bats with Apache License 2.0 6 votes vote down vote up
/** Returns the OGC type of a geometry. */
private static Type type(Geometry g) {
  switch (g.getType()) {
  case Point:
    return Type.POINT;
  case Polyline:
    return Type.LINESTRING;
  case Polygon:
    return Type.POLYGON;
  case MultiPoint:
    return Type.MULTIPOINT;
  case Envelope:
    return Type.POLYGON;
  case Line:
    return Type.LINESTRING;
  case Unknown:
    return Type.Geometry;
  default:
    throw new AssertionError(g);
  }
}
 
Example #9
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example #10
Source File: GeoFunctions.java    From Quicksql with MIT License 6 votes vote down vote up
/** Returns the OGC type of a geometry. */
private static Type type(Geometry g) {
  switch (g.getType()) {
  case Point:
    return Type.POINT;
  case Polyline:
    return Type.LINESTRING;
  case Polygon:
    return Type.POLYGON;
  case MultiPoint:
    return Type.MULTIPOINT;
  case Envelope:
    return Type.POLYGON;
  case Line:
    return Type.LINESTRING;
  case Unknown:
    return Type.Geometry;
  default:
    throw new AssertionError(g);
  }
}
 
Example #11
Source File: DemoTheatreApp.java    From arcgis-runtime-demo-java with Apache License 2.0 6 votes vote down vote up
private void highlightGeometry(Point point) {
  if (point == null) {
    return;
  }

  graphicsLayer.removeAll();
  graphicsLayer.addGraphic(
    new Graphic(point, new SimpleMarkerSymbol(Color.CYAN, 20, SimpleMarkerSymbol.Style.CIRCLE)));
  
  // -----------------------------------------------------------------------------------------
  // Zoom to the highlighted graphic
  // -----------------------------------------------------------------------------------------
  Geometry geometryForZoom = GeometryEngine.buffer(
    point, 
    map.getSpatialReference(), 
    map.getFullExtent().getWidth() * 0.10, 
    map.getSpatialReference().getUnit());
  map.zoomTo(geometryForZoom);
}
 
Example #12
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example #13
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example #14
Source File: GeoFunctions.java    From presto with Apache License 2.0 6 votes vote down vote up
@SqlNullable
@Description("Returns the lower left and upper right corners of bounding rectangular polygon of a Geometry")
@ScalarFunction("ST_EnvelopeAsPts")
@SqlType("array(" + GEOMETRY_TYPE_NAME + ")")
public static Block stEnvelopeAsPts(@SqlType(GEOMETRY_TYPE_NAME) Slice input)
{
    Envelope envelope = deserializeEnvelope(input);
    if (envelope.isEmpty()) {
        return null;
    }
    BlockBuilder blockBuilder = GEOMETRY.createBlockBuilder(null, 2);
    Point lowerLeftCorner = new Point(envelope.getXMin(), envelope.getYMin());
    Point upperRightCorner = new Point(envelope.getXMax(), envelope.getYMax());
    GEOMETRY.writeSlice(blockBuilder, serialize(createFromEsriGeometry(lowerLeftCorner, null, false)));
    GEOMETRY.writeSlice(blockBuilder, serialize(createFromEsriGeometry(upperRightCorner, null, false)));
    return blockBuilder.build();
}
 
Example #15
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(GeometryType t)
{
	String type = null;
	if(t == GeometryType.Point)
	{
		type = "esriGeometryPoint";
	}
	else if (t==GeometryType.Polyline)
	{
		type = "esriGeometryPolyline";
	}
	else if (t==GeometryType.Polygon)
	{
		type = "esriGeometryPolygon";
	}
	else if (t==GeometryType.MultiPoint)
	{
		type = "esriGeometryMultiPoint";
	}
	return type;
}
 
Example #16
Source File: GeoFunctions.java    From calcite with Apache License 2.0 6 votes vote down vote up
/** Returns the OGC type of a geometry. */
private static Type type(Geometry g) {
  switch (g.getType()) {
  case Point:
    return Type.POINT;
  case Polyline:
    return Type.LINESTRING;
  case Polygon:
    return Type.POLYGON;
  case MultiPoint:
    return Type.MULTIPOINT;
  case Envelope:
    return Type.POLYGON;
  case Line:
    return Type.LINESTRING;
  case Unknown:
    return Type.Geometry;
  default:
    throw new AssertionError(g);
  }
}
 
Example #17
Source File: BingTileFunctions.java    From presto with Apache License 2.0 6 votes vote down vote up
private static BingTile getTileCoveringLowerRightCorner(Envelope envelope, int zoomLevel)
{
    BingTile tile = latitudeLongitudeToTile(envelope.getYMin(), envelope.getXMax(), zoomLevel);

    // If the tile covering the lower right corner of the envelope overlaps the envelope only
    // at the border then return a tile shifted to the left and/or top
    int deltaX = 0;
    int deltaY = 0;
    Point upperLeftCorner = tileXYToLatitudeLongitude(tile.getX(), tile.getY(), tile.getZoomLevel());
    if (upperLeftCorner.getX() == envelope.getXMax()) {
        deltaX = -1;
    }
    if (upperLeftCorner.getY() == envelope.getYMin()) {
        deltaY = -1;
    }

    if (deltaX != 0 || deltaY != 0) {
        return BingTile.fromCoordinates(tile.getX() + deltaX, tile.getY() + deltaY, tile.getZoomLevel());
    }

    return tile;
}
 
Example #18
Source File: DijkstraBenchmark.java    From barefoot with Apache License 2.0 6 votes vote down vote up
@Test
public void testNoRouteBound() {
    Set<RoadPoint> sources = map.spatial().nearest(new Point(11.58424, 48.17635));
    Set<RoadPoint> targets = map.spatial().nearest(new Point(11.59151, 48.15231));

    assertTrue(!sources.isEmpty());
    assertTrue(!targets.isEmpty());

    RoadPoint source = sources.iterator().next();
    RoadPoint target = targets.iterator().next();

    Router<Road, RoadPoint> algo = new Dijkstra<>();

    Stopwatch sw = new Stopwatch();
    sw.start();
    List<Road> edges = algo.route(source, target, new Distance(), new Distance(), 10000d);
    sw.stop();

    assertTrue(edges == null);

    logger.info("no route bound example (fastest, priority): {} ms", sw.ms());
}
 
Example #19
Source File: GeofenceServiceFast.java    From arcgis-runtime-demos-android with Apache License 2.0 6 votes vote down vote up
/**
 * This action is handled in the provided background thread. It is called
 * when this service receives a location update from Google fusion API;
 * therefore no connection to the Google API client is required.
 */
private void handleActionCheckLocation(Location newLocation) {

  if(newLocation !=null) {
    // The incoming location is the current device location, in geographic coordinates.
    Point locationPoint = new Point(newLocation.getLongitude(), newLocation.getLatitude());
    LocalGeofence.FenceInformation info = LocalGeofence.latestLocation(locationPoint);
    Log.i(TAG, String.format("GeofenceServiceFast Status: %s, UpdateChange: %s, Change: %s", info.status, info.updateChange, info.change));

    if (info.change == LocalGeofence.Change.ENTERED) {
      sendNotification(String.format("Alert! Entered %s", LocalGeofence.getFeatureName()));
    }
    else if (info.change == LocalGeofence.Change.EXITED) {
      sendNotification(String.format("Exited %s", LocalGeofence.getFeatureName()));
    }

    if (LocalGeofence.UpdateChange.FASTER == info.updateChange) {
      // Ensure we are receiving updates frequently.
      handleActionStartFastUpdates();
    }
    else if (LocalGeofence.UpdateChange.SLOWER == info.updateChange) {
      // Ensure we are receiving updates less frequently.
      handleActionChangeToNormalUpdates();
    }
  }
}
 
Example #20
Source File: TestEsriJsonSerDe.java    From spatial-framework-for-hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void TestNullGeom() throws Exception {
       ArrayList<Object> stuff = new ArrayList<Object>();
	Properties proptab = new Properties();
	proptab.setProperty(HiveShims.serdeConstants.LIST_COLUMNS, "shape");
	proptab.setProperty(HiveShims.serdeConstants.LIST_COLUMN_TYPES, "binary");
	AbstractSerDe jserde = mkSerDe(proptab);
       StructObjectInspector rowOI = (StructObjectInspector)jserde.getObjectInspector();

       //value.set("{\"attributes\":{},\"geometry\":{\"x\":15.0,\"y\":5.0}}");
       addWritable(stuff, new Point(15.0, 5.0));
	Object row = runSerDe(stuff, jserde, rowOI);
	Object fieldData = getField("shape", row, rowOI);
	ckPoint(new Point(15.0, 5.0), (BytesWritable)fieldData);

       //value.set("{\"attributes\":{},\"geometry\":null}");
	stuff.set(0, null);
	row = runSerDe(stuff, jserde, rowOI);
	fieldData = getField("shape", row, rowOI);
	Assert.assertNull(fieldData);
}
 
Example #21
Source File: GeoFunctions.java    From presto with Apache License 2.0 6 votes vote down vote up
private static Point getPolygonSansHolesCentroid(Polygon polygon)
{
    int pointCount = polygon.getPointCount();
    double xSum = 0;
    double ySum = 0;
    double signedArea = 0;
    for (int i = 0; i < pointCount; i++) {
        Point current = polygon.getPoint(i);
        Point next = polygon.getPoint((i + 1) % polygon.getPointCount());
        double ladder = current.getX() * next.getY() - next.getX() * current.getY();
        xSum += (current.getX() + next.getX()) * ladder;
        ySum += (current.getY() + next.getY()) * ladder;
        signedArea += ladder / 2;
    }
    return new Point(xSum / (signedArea * 6), ySum / (signedArea * 6));
}
 
Example #22
Source File: GeometryUtils.java    From presto with Apache License 2.0 6 votes vote down vote up
public static int getPointCount(OGCGeometry ogcGeometry)
{
    GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor();
    int points = 0;
    while (true) {
        com.esri.core.geometry.Geometry geometry = cursor.next();
        if (geometry == null) {
            return points;
        }

        if (geometry.isEmpty()) {
            continue;
        }

        if (geometry instanceof Point) {
            points++;
        }
        else {
            points += ((MultiVertexGeometry) geometry).getPointCount();
        }
    }
}
 
Example #23
Source File: TestEsriJsonSerDe.java    From spatial-framework-for-hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void TestIntPoint() throws Exception {
       ArrayList<Object> stuff = new ArrayList<Object>();
	Properties proptab = new Properties();
	proptab.setProperty(HiveShims.serdeConstants.LIST_COLUMNS, "num,shape");
	proptab.setProperty(HiveShims.serdeConstants.LIST_COLUMN_TYPES, "bigint,binary");
	AbstractSerDe jserde = mkSerDe(proptab);
       StructObjectInspector rowOI = (StructObjectInspector)jserde.getObjectInspector();

       //value.set("{\"attributes\":{\"num\":7},\"geometry\":{\"x\":15.0,\"y\":5.0}}");
       addWritable(stuff, 7L);
       addWritable(stuff, new Point(15.0, 5.0));
	Object row = runSerDe(stuff, jserde, rowOI);
	Object fieldData = getField("num", row, rowOI);
	Assert.assertEquals(7, ((LongWritable)fieldData).get());

       //value.set("{\"attributes\":{\"num\":4},\"geometry\":{\"x\":7.0,\"y\":2.0}}");
	stuff.clear();
       addWritable(stuff, 4L);
       addWritable(stuff, new Point(7.0, 2.0));
	row = runSerDe(stuff, jserde, rowOI);
	fieldData = getField("num", row, rowOI);
	Assert.assertEquals(4, ((LongWritable)fieldData).get());
	fieldData = getField("shape", row, rowOI);
	ckPoint(new Point(7.0, 2.0), (BytesWritable)fieldData);
}
 
Example #24
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example #25
Source File: MainMenuJPanel.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private void jButton_navGoToMgrsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_navGoToMgrsActionPerformed
    Point pt = mapController.panTo(jTextField_navMgrs.getText());
    if (null != pt) {
        mgrsLayerController.showPoint(pt, mapController.getSpatialReference());
    } else {
        jLabel_mgrsMessage.setText("<html>Invalid MGRS string</html>");
    }
}
 
Example #26
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private Point ellipsePtFromAngle(Point center, double rh, double rv, double angle)
{
	double x = center.getX();
	double y = center.getY();
	double c = Math.cos(angle);
	double s = Math.sin(angle);
	double ta = s/c;
	double tt = ta * (rh/rv);
	double d = 1.0 / Math.sqrt(1.0 + Math.pow(tt, 2));
	double ex = x + Math.copySign(rh*d, c);
	double ey = y + Math.copySign(rv * tt * d, s);
	return new Point(ex,ey);
	
}
 
Example #27
Source File: VehicleCommanderJFrame.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private void jButton_clearMessagesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_clearMessagesActionPerformed
    ArrayList<String> layerNames = new ArrayList<>();
    String[] messageLayerNames = symbolController.getMessageLayerNames();
    for (String layerName : messageLayerNames) {
        layerNames.add(layerName);
    }
    ClearMessagesDialog dialog = ClearMessagesDialog.getInstance(this, false, layerNames, symbolController);
    java.awt.Point buttonLocation = jButton_clearMessages.getLocationOnScreen();
    dialog.setLocation(buttonLocation.x - dialog.getWidth() + jButton_clearMessages.getWidth(), buttonLocation.y + jButton_clearMessages.getHeight());
    dialog.setVisible(true);
}
 
Example #28
Source File: AddAndMoveGraphicsApp.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
private void addDynamicGraphics(int numberOfGraphicsToAdd) {

    double minx = mapExtent.getXMin();
    double maxx = mapExtent.getXMax();
    double miny= mapExtent.getYMin();
    double maxy = mapExtent.getYMax();

    int i = 0;
    while (i < numberOfGraphicsToAdd) {
      Point point = new Point((random.nextFloat()*(maxx-minx)) + minx, (random.nextFloat()*(maxy-miny)) + miny);
      int id = dynamicGraphicsLayer.addGraphic(new Graphic(point, null));
      latestDynamicPoints.put(Integer.valueOf(id), point);
      i++;
    }
  }
 
Example #29
Source File: SpatialQProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private MapGeometry constructGeometryFromString(String geoString) {
	String[] pairs = geoString.split(" ");

	Polygon polygon = new Polygon();
	Boolean firstit = true;
	for (String coords : pairs) {

		String[] tuple = coords.split(",");
		Double x = Double.parseDouble(tuple[0]);
		Double y = Double.parseDouble(tuple[1]);
		Point p = new Point(x, y);
		Double z = Double.NaN;
		if (tuple.length > 2) {
			z = Double.parseDouble(tuple[2]);
			p.setZ(z);
		}
		if (firstit) {
			polygon.startPath(p);
			firstit = false;
		} else {
			polygon.lineTo(p);
		}
	}
	polygon.closeAllPaths();
	MapGeometry mapgeo = new MapGeometry(polygon, srOut);
	return mapgeo;
}
 
Example #30
Source File: BufferProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
@Override
public GeoEvent process(GeoEvent ge) throws Exception {
	String radiusSource = properties.get("radiusSource").getValue().toString();
	double radius;
	if(radiusSource.equals("Constant"))
	{
		radius = (Double)properties.get("radius").getValue();
	}
	else
	{
		String eventfld = properties.get("radiusEvent").getValue().toString();
		String[] arr = eventfld.split(":");
		radius = (Double)ge.getField(arr[1]);
	}
	
	
	String units = properties.get("units").getValue().toString();
	int inwkid = (Integer) properties.get("wkidin").getValue();
	int outwkid = (Integer) properties.get("wkidout").getValue();
	int bufferwkid = (Integer) properties.get("wkidbuffer").getValue();
	com.esri.ges.spatial.Point eventGeo = (com.esri.ges.spatial.Point) ge.getGeometry();
	double x = eventGeo.getX();
	double y = eventGeo.getY();
	com.esri.ges.spatial.Geometry buffer = constructBuffer(x,y,radius,units,inwkid,bufferwkid,outwkid);
	ge.setGeometry(buffer);
	return ge;
}