Java Code Examples for com.esri.core.geometry.Point#setY()
The following examples show how to use
com.esri.core.geometry.Point#setY() .
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: BufferProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private com.esri.ges.spatial.Geometry constructBuffer(double x, double y, double radius, String units, int wkidin, int wkidbuffer, int wkidout) throws GeometryException { Point center = new Point(); center.setX(x); center.setY(y); SpatialReference srIn = SpatialReference.create(wkidin); SpatialReference srBuffer = SpatialReference.create(wkidbuffer); SpatialReference srOut = SpatialReference.create(wkidout); UnitConverter uc = new UnitConverter(); String c_name = uc.findConnonicalName(units); int unitout = uc.findWkid(c_name); Unit u = new LinearUnit(unitout); Point centerProj = (Point) GeometryEngine.project(center, srIn, srBuffer); Geometry buffer = GeometryEngine.buffer(centerProj, srBuffer, radius, u); Geometry bufferout = GeometryEngine.project(buffer, srBuffer, srOut); String json = GeometryEngine.geometryToJson(srOut, bufferout); return spatial.fromJson(json); }
Example 2
Source File: EllipseProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private MapGeometry constructEllipse(double x, double y, double majorAxis, double minorAxis, double rotation, int wkidin, int wkidbuffer, int wkidout) { Point center = new Point(); center.setX(x); center.setY(y); SpatialReference srIn = SpatialReference.create(wkidin); SpatialReference srBuffer = SpatialReference.create(wkidbuffer); SpatialReference srOut = SpatialReference.create(wkidout); UnitConverter uc = new UnitConverter(); majorAxis = uc.Convert(majorAxis, units, srBuffer); minorAxis = uc.Convert(minorAxis, units, srBuffer); Point centerProj = (Point) GeometryEngine.project(center, srIn, srBuffer); GeometryUtility geoutil = new GeometryUtility(); Polygon ellipse = geoutil.GenerateEllipse(centerProj, majorAxis, minorAxis, rotation); Geometry ellipseOut = GeometryEngine.project(ellipse, srBuffer, srOut); MapGeometry mapGeo = new MapGeometry(ellipseOut, srOut); return mapGeo; }
Example 3
Source File: BufferProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private Geometry constructBuffer(double x, double y, double radius, String units, int wkidin, int wkidbuffer, int wkidout) { Point center = new Point(); center.setX(x); center.setY(y); SpatialReference srIn = SpatialReference.create(wkidin); SpatialReference srBuffer = SpatialReference.create(wkidbuffer); SpatialReference srOut = SpatialReference.create(wkidout); UnitConverter uc = new UnitConverter(); String c_name = uc.findConnonicalName(units); int unitout = uc.findWkid(c_name); Unit u = LinearUnit.create(unitout); Point centerProj = (Point) GeometryEngine.project(center, srIn, srBuffer); Geometry buffer = GeometryEngine .buffer(centerProj, srBuffer, radius, u); Geometry bufferout = GeometryEngine.project(buffer, srBuffer, srOut); //String json = GeometryEngine.geometryToJson(srOut, bufferout); return bufferout; }
Example 4
Source File: EllipseProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private com.esri.ges.spatial.Geometry constructEllipse(double x, double y, double majorAxis, double minorAxis, double rotation, int wkidin, int wkidbuffer, int wkidout) throws GeometryException { Point center = new Point(); center.setX(x); center.setY(y); SpatialReference srIn = SpatialReference.create(wkidin); SpatialReference srBuffer = SpatialReference.create(wkidbuffer); SpatialReference srOut = SpatialReference.create(wkidout); Point centerProj = (Point) GeometryEngine.project(center, srIn, srBuffer); GeometryUtility geoutil = new GeometryUtility(); Polygon ellipse = geoutil.GenerateEllipse(centerProj, majorAxis, minorAxis, rotation); Geometry ellipseOut = GeometryEngine.project(ellipse, srBuffer, srOut); String json = GeometryEngine.geometryToJson(srOut, ellipseOut); return spatial.fromJson(json); }
Example 5
Source File: RangeFanProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private Geometry constructRangeFan(double x, double y, double range, String unit, double bearing, double traversal) throws GeometryException { Polygon fan = new Polygon(); Point center = new Point(); center.setX(x); center.setY(y); // SpatialReference srIn = SpatialReference.create(wkidin); // SpatialReference srBuffer = SpatialReference.create(wkidbuffer); // SpatialReference srOut = SpatialReference.create(wkidout); Point centerProj = (Point) GeometryEngine.project(center, srIn, srBuffer); double centerX = centerProj.getX(); double centerY = centerProj.getY(); bearing = GeometryUtility.Geo2Arithmetic(bearing); double leftAngle = bearing - (traversal / 2); double rightAngle = bearing + (traversal / 2); int count = (int) Math.round(Math.abs(leftAngle - rightAngle)); fan.startPath(centerProj); UnitConverter uc = new UnitConverter(); range = uc.Convert(range, unit, srBuffer); for (int i = 0; i < count; ++i) { double d = Math.toRadians(leftAngle + i); double arcX = centerX + (range * Math.cos(d)); double arcY = centerY + (range * Math.sin(d)); Point arcPt = new Point(arcX, arcY); // arcPt = (Point) GeometryEngine.project(arcPt, srBuffer, srOut); fan.lineTo(arcPt); } fan.closeAllPaths(); return fan; }
Example 6
Source File: RangeFanProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private Geometry constructRangeFan(double x, double y, double range, String unit, double bearing, double traversal) throws Exception { try { Polygon fan = new Polygon(); Point center = new Point(); center.setX(x); center.setY(y); Point centerProj = (Point) GeometryEngine.project(center, srIn, srBuffer); double centerX = centerProj.getX(); double centerY = centerProj.getY(); bearing = GeometryUtility.Geo2Arithmetic(bearing); double leftAngle = bearing - (traversal / 2); double rightAngle = bearing + (traversal / 2); int count = (int) Math.round(Math.abs(leftAngle - rightAngle)); fan.startPath(centerProj); UnitConverter uc = new UnitConverter(); range = uc.Convert(range, unit, srBuffer); for (int i = 0; i < count; ++i) { double d = Math.toRadians(leftAngle + i); double arcX = centerX + (range * Math.cos(d)); double arcY = centerY + (range * Math.sin(d)); Point arcPt = new Point(arcX, arcY); fan.lineTo(arcPt); } fan.closeAllPaths(); return fan; } catch (Exception e) { LOG.error(e.getMessage()); throw e; } }
Example 7
Source File: GeoFunctions.java From presto with Apache License 2.0 | 4 votes |
private static List<Point> interpolatePoints(OGCGeometry geometry, double fractionStep, boolean repeated) { validateType("line_interpolate_point", geometry, EnumSet.of(LINE_STRING)); if (fractionStep < 0 || fractionStep > 1) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "fraction must be between 0 and 1"); } MultiPath path = (MultiPath) geometry.getEsriGeometry(); if (fractionStep == 0) { return Collections.singletonList(path.getPoint(0)); } if (fractionStep == 1) { return Collections.singletonList((path.getPoint(path.getPointCount() - 1))); } int pointCount = repeated ? (int) Math.floor(1 / fractionStep) : 1; List<Point> interpolatedPoints = new ArrayList<>(pointCount); double lineStringLength = path.calculateLength2D(); Point previous = path.getPoint(0); double fractionConsumed = 0.0; double fractionIncrement = fractionStep; for (int i = 1; i < path.getPointCount() && interpolatedPoints.size() < pointCount; i++) { Point current = path.getPoint(i); double segmentLengthFraction = GeometryEngine.distance(previous, current, null) / lineStringLength; while (fractionStep < fractionConsumed + segmentLengthFraction && interpolatedPoints.size() < pointCount) { double segmentFraction = (fractionStep - fractionConsumed) / segmentLengthFraction; Point point = new Point(); point.setX(previous.getX() + (current.getX() - previous.getX()) * segmentFraction); point.setY(previous.getY() + (current.getY() - previous.getY()) * segmentFraction); interpolatedPoints.add(point); fractionStep += fractionIncrement; } fractionConsumed += segmentLengthFraction; previous = current; } if (interpolatedPoints.size() < pointCount) { interpolatedPoints.add(path.getPoint(path.getPointCount() - 1)); } return interpolatedPoints; }