com.vividsolutions.jts.geom.impl.CoordinateArraySequence Java Examples
The following examples show how to use
com.vividsolutions.jts.geom.impl.CoordinateArraySequence.
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: GeometryUtils.java From gama with GNU General Public License v3.0 | 5 votes |
public static ICoordinates getContourCoordinates(final Polygon g) { if (g.isEmpty()) { return ICoordinates.EMPTY; } if (g.getExteriorRing().getCoordinateSequence() instanceof CoordinateArraySequence) { return GEOMETRY_FACTORY.getCoordinateSequenceFactory().create(g.getExteriorRing().getCoordinates()); } return (ICoordinates) g.getExteriorRing().getCoordinateSequence(); }
Example #2
Source File: GeoJsonReader.java From jts with GNU Lesser General Public License v2.1 | 5 votes |
private CoordinateSequence createCoordinate(List<Number> ordinates) { CoordinateSequence result = new CoordinateArraySequence(1); if (ordinates.size() > 0) { result.setOrdinate(0, 0, ordinates.get(0).doubleValue()); } if (ordinates.size() > 1) { result.setOrdinate(0, 1, ordinates.get(1).doubleValue()); } if (ordinates.size() > 2) { result.setOrdinate(0, 2, ordinates.get(2).doubleValue()); } return result; }
Example #3
Source File: TrianglePredicate.java From jts with GNU Lesser General Public License v2.1 | 5 votes |
/** * Checks if the computed value for isInCircle is correct, using * double-double precision arithmetic. * * @param a a vertex of the triangle * @param b a vertex of the triangle * @param c a vertex of the triangle * @param p the point to test */ private static void checkRobustInCircle(Coordinate a, Coordinate b, Coordinate c, Coordinate p) { boolean nonRobustInCircle = isInCircleNonRobust(a, b, c, p); boolean isInCircleDD = TrianglePredicate.isInCircleDDSlow(a, b, c, p); boolean isInCircleCC = TrianglePredicate.isInCircleCC(a, b, c, p); Coordinate circumCentre = Triangle.circumcentre(a, b, c); System.out.println("p radius diff a = " + Math.abs(p.distance(circumCentre) - a.distance(circumCentre)) / a.distance(circumCentre)); if (nonRobustInCircle != isInCircleDD || nonRobustInCircle != isInCircleCC) { System.out.println("inCircle robustness failure (double result = " + nonRobustInCircle + ", DD result = " + isInCircleDD + ", CC result = " + isInCircleCC + ")"); System.out.println(WKTWriter.toLineString(new CoordinateArraySequence( new Coordinate[] { a, b, c, p }))); System.out.println("Circumcentre = " + WKTWriter.toPoint(circumCentre) + " radius = " + a.distance(circumCentre)); System.out.println("p radius diff a = " + Math.abs(p.distance(circumCentre)/a.distance(circumCentre) - 1)); System.out.println("p radius diff b = " + Math.abs(p.distance(circumCentre)/b.distance(circumCentre) - 1)); System.out.println("p radius diff c = " + Math.abs(p.distance(circumCentre)/c.distance(circumCentre) - 1)); System.out.println(); } }
Example #4
Source File: TriPredicate.java From jts with GNU Lesser General Public License v2.1 | 5 votes |
/** * Checks if the computed value for isInCircle is correct, using * double-double precision arithmetic. * * @param a a vertex of the triangle * @param b a vertex of the triangle * @param c a vertex of the triangle * @param p the point to test */ private static void checkRobustInCircle(Coordinate a, Coordinate b, Coordinate c, Coordinate p) { boolean nonRobustInCircle = isInCircle(a, b, c, p); boolean isInCircleDD = TriPredicate.isInCircleDD(a, b, c, p); boolean isInCircleCC = TriPredicate.isInCircleCC(a, b, c, p); Coordinate circumCentre = Triangle.circumcentre(a, b, c); System.out.println("p radius diff a = " + Math.abs(p.distance(circumCentre) - a.distance(circumCentre)) / a.distance(circumCentre)); if (nonRobustInCircle != isInCircleDD || nonRobustInCircle != isInCircleCC) { System.out.println("inCircle robustness failure (double result = " + nonRobustInCircle + ", DD result = " + isInCircleDD + ", CC result = " + isInCircleCC + ")"); System.out.println(WKTWriter.toLineString(new CoordinateArraySequence( new Coordinate[] { a, b, c, p }))); System.out.println("Circumcentre = " + WKTWriter.toPoint(circumCentre) + " radius = " + a.distance(circumCentre)); System.out.println("p radius diff a = " + Math.abs(p.distance(circumCentre)/a.distance(circumCentre) - 1)); System.out.println("p radius diff b = " + Math.abs(p.distance(circumCentre)/b.distance(circumCentre) - 1)); System.out.println("p radius diff c = " + Math.abs(p.distance(circumCentre)/c.distance(circumCentre) - 1)); System.out.println(); } }
Example #5
Source File: SimpleDemo.java From jts with GNU Lesser General Public License v2.1 | 5 votes |
private void testGwtRpcAndWktAndWkb() { FeatureServiceAsync features = GWT.create(FeatureService.class); CoordinateSequence cs = new CoordinateArraySequence(new Coordinate[] { new Coordinate(1, 2, 3), new Coordinate(4, 5) }); sLogger.info("CoordinateSequence: " + cs); sLogger.info("Copied CS: " + CoordinateSequences.copy(cs)); final Geometry g = demonstrateGeometryAndWktWriter(); demonstrateWkb(); Feature feature = new Feature(); feature.fid = "feature.1"; feature.geometry = g; feature.properties = new HashMap<String, String>(); feature.properties.put("name", "JTS!"); sLogger.info("Original feature: " + feature); features.echo(feature, new AsyncCallback<Feature>() { public void onSuccess(Feature result) { sLogger.info("Echoed feature: " + result); } public void onFailure(Throwable caught) { sLogger.log(Level.WARNING, "Unable to make GWT-RPC request", caught); } }); }
Example #6
Source File: DirectionsService.java From jdal with Apache License 2.0 | 5 votes |
private LineString decodePolyline(String encoded) { List<Coordinate> coordinates = new ArrayList<Coordinate>(); int index = 0, len = encoded.length(); int lat = 0, lng = 0; while (index < len) { int b, shift = 0, result = 0; do { b = encoded.charAt(index++) - 63; result |= (b & 0x1f) << shift; shift += 5; } while (b >= 0x20); int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1)); lat += dlat; shift = 0; result = 0; do { b = encoded.charAt(index++) - 63; result |= (b & 0x1f) << shift; shift += 5; } while (b >= 0x20); int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1)); lng += dlng; coordinates.add(new Coordinate(lat/1E5, lng/1E5 )); } return new LineString(new CoordinateArraySequence(coordinates.toArray(new Coordinate[] {})), factory); }
Example #7
Source File: BasicSegmentString.java From jts with GNU Lesser General Public License v2.1 | 4 votes |
public String toString() { return WKTWriter.toLineString(new CoordinateArraySequence(pts)); }
Example #8
Source File: NodedSegmentString.java From jts with GNU Lesser General Public License v2.1 | 4 votes |
public String toString() { return WKTWriter.toLineString(new CoordinateArraySequence(pts)); }
Example #9
Source File: RouteRequest.java From jdal with Apache License 2.0 | 4 votes |
private Point getPoint(double lat, double lon) { Coordinate coordinate = new Coordinate(lat, lon); CoordinateSequence coordinates = new CoordinateArraySequence(new Coordinate[] {coordinate}); return new Point(coordinates, new GeometryFactory(new PrecisionModel(), 4326)); }
Example #10
Source File: EdgeRing.java From jts with GNU Lesser General Public License v2.1 | 2 votes |
/** * Gets a string representation of this object. * * @return a string representing the object */ public String toString() { return WKTWriter.toLineString(new CoordinateArraySequence(getCoordinates())); }