Java Code Examples for com.esri.core.geometry.Point#getY()
The following examples show how to use
com.esri.core.geometry.Point#getY() .
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: GeoFunctions.java From presto with Apache License 2.0 | 6 votes |
private static Point computeLineCentroid(Polyline polyline) { double xSum = 0; double ySum = 0; double weightSum = 0; for (int i = 0; i < polyline.getPathCount(); i++) { Point startPoint = polyline.getPoint(polyline.getPathStart(i)); Point endPoint = polyline.getPoint(polyline.getPathEnd(i) - 1); double dx = endPoint.getX() - startPoint.getX(); double dy = endPoint.getY() - startPoint.getY(); double length = sqrt(dx * dx + dy * dy); weightSum += length; xSum += (startPoint.getX() + endPoint.getX()) * length / 2; ySum += (startPoint.getY() + endPoint.getY()) * length / 2; } return new Point(xSum / weightSum, ySum / weightSum); }
Example 2
Source File: BufferProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
@Override public GeoEvent process(GeoEvent ge) throws Exception { // Operation phase... if (radius == null) { radius = (Double) ge.getField(bufferEventFld); if (radius == null) { Exception e = new Exception("Radius is not defined in geoevent"); throw (e); } } MapGeometry mapGeo = ge.getGeometry(); Point eventGeo = (Point) mapGeo.getGeometry(); double x = eventGeo.getX(); double y = eventGeo.getY(); int inwkid = mapGeo.getSpatialReference().getID(); //int inwkid = eventGeo.getSpatialReference().getWkid(); Geometry buffer = constructBuffer(x, y, radius, units, inwkid, bufferwkid, outwkid); SpatialReference srOut = SpatialReference.create(outwkid); MapGeometry outMapGeo = new MapGeometry(buffer, srOut); ge.setGeometry(outMapGeo); return ge; }
Example 3
Source File: GeoFunctions.java From presto with Apache License 2.0 | 6 votes |
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 4
Source File: BingTileFunctions.java From presto with Apache License 2.0 | 6 votes |
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 5
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
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 6
Source File: EllipseProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
@Override public GeoEvent process(GeoEvent ge) throws Exception { if(!ge.getGeoEventDefinition().getTagNames().contains("GEOMETRY")) { return null; } inwkid = ge.getGeometry().getSpatialReference().getID(); if(majAxisSource.equals("Event")) { majorAxisRadius = (Double)ge.getField(majorAxisField); } if(minAxisSource.equals("Event")) { minorAxisRadius = (Double)ge.getField(minorAxisField); } if(rotSource.equals("Event")) { rotation=(Double)ge.getField(rotationField); } MapGeometry mapGeo = ge.getGeometry(); Geometry geo = mapGeo.getGeometry(); if(!(geo instanceof Point)) { return null; } Point eventGeo = (Point)geo; double x = eventGeo.getX(); double y = eventGeo.getY(); double rdeg = GeometryUtility.Geo2Arithmetic(rotation); double r = Math.toRadians(rdeg); MapGeometry ellipse = constructEllipse(x, y, majorAxisRadius, minorAxisRadius, r, inwkid, procwkid, outwkid); ge.setGeometry(ellipse); return ge; }
Example 7
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private static Point _rotate(Point center, Point inPt, double ra) { double x = inPt.getX(); double y = inPt.getY(); double cx = center.getX(); double cy = center.getY(); double cosra = Math.cos(ra); double sinra = Math.sin(ra); double rx = cx + cosra * (x - cx) - sinra * (y - cy); double ry = cy + sinra * (x - cx) + cosra * (y-cy); Point rPt = new Point(rx,ry); return rPt; }
Example 8
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
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 9
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private static Point _rotate(Point center, Point inPt, double ra) { double x = inPt.getX(); double y = inPt.getY(); double cx = center.getX(); double cy = center.getY(); double cosra = Math.cos(ra); double sinra = Math.sin(ra); double rx = cx + cosra * (x - cx) - sinra * (y - cy); double ry = cy + sinra * (x - cx) + cosra * (y-cy); Point rPt = new Point(rx,ry); return rPt; }
Example 10
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private static Point _rotate(Point center, Point inPt, double ra) { double x = inPt.getX(); double y = inPt.getY(); double cx = center.getX(); double cy = center.getY(); double cosra = Math.cos(ra); double sinra = Math.sin(ra); double rx = cx + cosra * (x - cx) - sinra * (y - cy); double ry = cy + sinra * (x - cx) + cosra * (y-cy); Point rPt = new Point(rx,ry); return rPt; }
Example 11
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
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 12
Source File: MyoMapListener.java From arcgis-runtime-demos-android with Apache License 2.0 | 5 votes |
@Override public void run() { // zoom the map Point center = mMapView.getCenter(); double newX = center.getX() + (PAN_AMOUNT * (mMapView.getScale()/SCALE_DIV) * xFactor); double newY = center.getY() + (PAN_AMOUNT * (mMapView.getScale()/SCALE_DIV) * yFactor); mMapView.centerAt(new Point(newX, newY), false); }
Example 13
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private static Point _rotate(Point center, Point inPt, double ra) { double x = inPt.getX(); double y = inPt.getY(); double cx = center.getX(); double cy = center.getY(); double cosra = Math.cos(ra); double sinra = Math.sin(ra); double rx = cx + cosra * (x - cx) - sinra * (y - cy); double ry = cy + sinra * (x - cx) + cosra * (y-cy); Point rPt = new Point(rx,ry); return rPt; }
Example 14
Source File: GeoFunctions.java From presto with Apache License 2.0 | 5 votes |
private static Point computePointsCentroid(MultiVertexGeometry multiVertex) { double xSum = 0; double ySum = 0; for (int i = 0; i < multiVertex.getPointCount(); i++) { Point point = multiVertex.getPoint(i); xSum += point.getX(); ySum += point.getY(); } return new Point(xSum / multiVertex.getPointCount(), ySum / multiVertex.getPointCount()); }
Example 15
Source File: GeoFunctions.java From presto with Apache License 2.0 | 5 votes |
private static Point computeMultiPolygonCentroid(OGCMultiPolygon multiPolygon) { double xSum = 0; double ySum = 0; double weightSum = 0; for (int i = 0; i < multiPolygon.numGeometries(); i++) { Point centroid = computePolygonCentroid((Polygon) multiPolygon.geometryN(i).getEsriGeometry()); Polygon polygon = (Polygon) multiPolygon.geometryN(i).getEsriGeometry(); double weight = polygon.calculateArea2D(); weightSum += weight; xSum += centroid.getX() * weight; ySum += centroid.getY() * weight; } return new Point(xSum / weightSum, ySum / weightSum); }
Example 16
Source File: PdfUtils.java From geoportal-server-harvester with Apache License 2.0 | 5 votes |
/** * Generates a bounding-box string from the given set of points * * @param points the points to find a bounding-box for * * @returns a bounding box string in the form "latMin lonMin, latMax lonMax" */ private static final String generateBbox(MultiPoint points) { int count = points.getPointCount(); Double xMax = -Double.MAX_VALUE; Double yMax = -Double.MAX_VALUE; Double xMin = Double.MAX_VALUE; Double yMin = Double.MAX_VALUE; for (int i = 0; i < count; i++) { Point pt = points.getPoint(i); if (pt.getX() > xMax) { xMax = pt.getX(); } if (pt.getX() < xMin) { xMin = pt.getX(); } if (pt.getY() > yMax) { yMax = pt.getY(); } if (pt.getY() < yMin) { yMin = pt.getY(); } } return String.format("%s %s, %s %s", xMin, yMin, xMax, yMax); }
Example 17
Source File: MapController.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 4 votes |
@Override public double[] projectPoint(double x, double y, int fromWkid, int toWkid) { Point pt = (Point) GeometryEngine.project(new Point(x, y), SpatialReference.create(fromWkid), SpatialReference.create(toWkid)); return new double[] { pt.getX(), pt.getY() }; }
Example 18
Source File: LatLongProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 4 votes |
private Geometry findBoundingBox(String mgrs, int accuracy, Point mgrsPt) { String mgrsZone = mgrs.substring(0, 1); int wkid = 0; String utm = null; if(mgrsZone.equals("A") || mgrsZone.equals("B") ) { wkid = 32761; } else if(mgrsZone.equals("Y") || mgrsZone.equals("Z")) { wkid = 32661; } else { PeGeogcs peGeoCS = PeFactory.geogcs(4326); double[] coordArray = {mgrsPt.getX(), mgrsPt.getY()}; String[] utmArray = new String[1]; PeNotationUtm.geog_to_utm(peGeoCS, 1, coordArray, PeNotationUtm.PE_UTM_OPTS_NS, utmArray); utm=utmArray[0]; wkid=GetWkidFromUTM(utm); } SpatialReference pcs = SpatialReference.create(wkid); SpatialReference gcs = SpatialReference.create(4326); Geometry projGeo = GeometryEngine.project(mgrsPt, gcs, pcs);//projec local Point projPt = (Point)projGeo; double dist = getDistFromAccuracy(accuracy); double xmin, ymin, xmax, ymax; xmin=projPt.getX(); ymin=projPt.getY(); xmax = xmin + dist; ymax = ymin + dist; Polygon pbb = new Polygon(); pbb.startPath(xmin, ymin); pbb.lineTo(xmax, ymin); pbb.lineTo(xmax, ymax); pbb.lineTo(xmin, ymax); pbb.lineTo(xmin, ymin); pbb.closeAllPaths(); Geometry bb = GeometryEngine.project(pbb, pcs, gcs);//project back to wgs84 return bb; }
Example 19
Source File: MGRSProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 4 votes |
@Override public GeoEvent process(GeoEvent evt) throws Exception { MapGeometry mapGeo = (MapGeometry) evt.getField(geofld); Geometry geo = mapGeo.getGeometry(); int wkid = mapGeo.getSpatialReference().getID(); if(wkid != 4326) { return null; } if(geo.getType() != Geometry.Type.Point) { return null; } Point pt = (Point)geo; double[] coords = {pt.getX(), pt.getY()}; PeGeogcs pegeocs = PeFactory.geogcs(4326); String[] mgrsvals = new String[1]; PeNotationMgrs.geog_to_mgrs(pegeocs, 1, coords, accuracy, false, mgrsvals); String mgrs = mgrsvals[0]; //LL ll = new LL(pt.getX(), pt.getY()); //ll.setAccuracy(accuracy); //MGRS2LatLongConverter converter = new MGRS2LatLongConverter(); //String mgrs = converter.LL2MRGS(ll); GeoEventDefinition edOut; GeoEventDefinition geoDef = evt.getGeoEventDefinition(); if((edOut=manager.searchGeoEventDefinition(newdef, getId()))==null) { edOut = geoDef.augment(fds); edOut.setOwner(getId()); edOut.setName(newdef); manager.addGeoEventDefinition(edOut); } GeoEventCreator geoEventCreator = messaging.createGeoEventCreator(); GeoEvent geOut = geoEventCreator.create(edOut.getGuid(), new Object[] { evt.getAllFields(), mgrs }); geOut.setProperty(GeoEventPropertyName.TYPE, "message"); geOut.setProperty(GeoEventPropertyName.OWNER_ID, getId()); geOut.setProperty(GeoEventPropertyName.OWNER_ID, definition.getUri()); return geOut; }
Example 20
Source File: BingTileFunctions.java From presto with Apache License 2.0 | 4 votes |
private static Envelope tileToEnvelope(BingTile tile) { Point upperLeftCorner = tileXYToLatitudeLongitude(tile.getX(), tile.getY(), tile.getZoomLevel()); Point lowerRightCorner = tileXYToLatitudeLongitude(tile.getX() + 1, tile.getY() + 1, tile.getZoomLevel()); return new Envelope(upperLeftCorner.getX(), lowerRightCorner.getY(), lowerRightCorner.getX(), upperLeftCorner.getY()); }