org.locationtech.jts.geom.CoordinateList Java Examples
The following examples show how to use
org.locationtech.jts.geom.CoordinateList.
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: GeometryTranslator.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Builds a line feature from a dwg polyline 3D. * * TODO handle these as contourlines * */ public SimpleFeature convertDwgPolyline3D( String typeName, String layerName, DwgPolyline3D polyline3d, int id ) { double[][] ptos = polyline3d.getPts(); CoordinateList coordList = new CoordinateList(); if (ptos != null) { for( int j = 0; j < ptos.length; j++ ) { Coordinate coord = new Coordinate(ptos[j][0], ptos[j][1], ptos[j][2]); coordList.add(coord); } SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName(typeName); b.setCRS(crs); b.add(THE_GEOM, LineString.class); b.add(LAYER, String.class); SimpleFeatureType type = b.buildFeatureType(); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); Geometry lineString = gF.createLineString(coordList.toCoordinateArray()); Object[] values = new Object[]{lineString, layerName}; builder.addAll(values); return builder.buildFeature(typeName + "." + id); } return null; }
Example #2
Source File: GeometryTranslator.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Builds a line feature from a dwg polyline 2D. * */ public SimpleFeature convertDwgPolyline2D( String typeName, String layerName, DwgPolyline2D polyline2d, int id ) { Point2D[] ptos = polyline2d.getPts(); CoordinateList coordList = new CoordinateList(); if (ptos != null) { for( int j = 0; j < ptos.length; j++ ) { Coordinate coord = new Coordinate(ptos[j].getX(), ptos[j].getY(), 0.0); coordList.add(coord); } SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName(typeName); b.setCRS(crs); b.add(THE_GEOM, LineString.class); b.add(LAYER, String.class); SimpleFeatureType type = b.buildFeatureType(); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); Geometry lineString = gF.createLineString(coordList.toCoordinateArray()); Object[] values = new Object[]{lineString, layerName}; builder.addAll(values); return builder.buildFeature(typeName + "." + id); } return null; }
Example #3
Source File: GeometryTranslator.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Builds a line feature from a dwg polyline 2D. * */ public SimpleFeature convertDwgLwPolyline( String typeName, String layerName, DwgLwPolyline lwPolyline, int id ) { Point2D[] ptos = lwPolyline.getVertices(); if (ptos != null) { CoordinateList coordList = new CoordinateList(); for( int j = 0; j < ptos.length; j++ ) { Coordinate coord = new Coordinate(ptos[j].getX(), ptos[j].getY(), 0.0); coordList.add(coord); } SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName(typeName); b.setCRS(crs); b.add(THE_GEOM, LineString.class); b.add(LAYER, String.class); SimpleFeatureType type = b.buildFeatureType(); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); Geometry lineString = gF.createLineString(coordList.toCoordinateArray()); Object[] values = new Object[]{lineString, layerName}; builder.addAll(values); return builder.buildFeature(typeName + "." + id); } return null; }
Example #4
Source File: GeometryTranslator.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Builds a point feature from a dwg point. */ public SimpleFeature convertDwgPoint( String typeName, String layerName, DwgPoint point, int id ) { double[] p = point.getPoint(); Point2D pto = new Point2D.Double(p[0], p[1]); CoordinateList coordList = new CoordinateList(); Coordinate coord = new Coordinate(pto.getX(), pto.getY(), 0.0); coordList.add(coord); SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName(typeName); b.setCRS(crs); b.add(THE_GEOM, MultiPoint.class); b.add(LAYER, String.class); SimpleFeatureType type = b.buildFeatureType(); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); Geometry points = gF.createMultiPoint(coordList.toCoordinateArray()); Object[] values = new Object[]{points, layerName}; builder.addAll(values); return builder.buildFeature(typeName + "." + id); }
Example #5
Source File: GeometryTranslator.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Builds a line feature from a dwg line. * */ public SimpleFeature convertDwgLine( String typeName, String layerName, DwgLine line, int id ) { double[] p1 = line.getP1(); double[] p2 = line.getP2(); Point2D[] ptos = new Point2D[]{new Point2D.Double(p1[0], p1[1]), new Point2D.Double(p2[0], p2[1])}; CoordinateList coordList = new CoordinateList(); for( int j = 0; j < ptos.length; j++ ) { Coordinate coord = new Coordinate(ptos[j].getX(), ptos[j].getY(), 0.0); coordList.add(coord); } SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName(typeName); b.setCRS(crs); b.add(THE_GEOM, LineString.class); b.add(LAYER, String.class); SimpleFeatureType type = b.buildFeatureType(); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); Geometry lineString = gF.createLineString(coordList.toCoordinateArray()); Object[] values = new Object[]{lineString, layerName}; builder.addAll(values); return builder.buildFeature(typeName + "." + id); }
Example #6
Source File: DxfVERTEX.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
public static DxfGroup readEntity(RandomAccessFile raf, CoordinateList coordList) throws IOException { Coordinate coord; double x=Double.NaN, y=Double.NaN, z=Double.NaN; DxfGroup group; try { while (null != (group = DxfGroup.readGroup(raf)) && group.getCode()!=0) { if (group.getCode()==10) x = group.getDoubleValue(); else if (group.getCode()==20) y = group.getDoubleValue(); else if (group.getCode()==30) z = group.getDoubleValue(); else {} } if (!Double.isNaN(x) && !Double.isNaN(y)) { coordList.add(new Coordinate(x,y,z)); } } catch (IOException ioe) {throw ioe;} return group; }
Example #7
Source File: GeometryTranslator.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Builds a polygon feature from a dwg solid. * */ public SimpleFeature convertDwgSolid( String typeName, String layerName, DwgSolid solid, int id ) { double[] p1 = solid.getCorner1(); double[] p2 = solid.getCorner2(); double[] p3 = solid.getCorner3(); double[] p4 = solid.getCorner4(); Point2D[] ptos = new Point2D[]{new Point2D.Double(p1[0], p1[1]), new Point2D.Double(p2[0], p2[1]), new Point2D.Double(p3[0], p3[1]), new Point2D.Double(p4[0], p4[1])}; CoordinateList coordList = new CoordinateList(); for( int j = 0; j < ptos.length; j++ ) { Coordinate coord = new Coordinate(ptos[j].getX(), ptos[j].getY()); coordList.add(coord); } coordList.closeRing(); SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName(typeName); b.setCRS(crs); b.add(THE_GEOM, Polygon.class); b.add(LAYER, String.class); SimpleFeatureType type = b.buildFeatureType(); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); LinearRing linearRing = gF.createLinearRing(coordList.toCoordinateArray()); Geometry polygon = gF.createPolygon(linearRing, null); Object[] values = new Object[]{polygon, layerName}; builder.addAll(values); return builder.buildFeature(typeName + "." + id); }
Example #8
Source File: GeometryTranslator.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Builds a line feature from a dwg arc. */ public SimpleFeature convertDwgArc( String typeName, String layerName, DwgArc arc, int id ) { double[] c = arc.getCenter(); Point2D center = new Point2D.Double(c[0], c[1]); double radius = (arc).getRadius(); double initAngle = Math.toDegrees((arc).getInitAngle()); double endAngle = Math.toDegrees((arc).getEndAngle()); Point2D[] ptos = GisModelCurveCalculator.calculateGisModelArc(center, radius, initAngle, endAngle); CoordinateList coordList = new CoordinateList(); for( int j = 0; j < ptos.length; j++ ) { Coordinate coord = new Coordinate(ptos[j].getX(), ptos[j].getY(), 0.0); coordList.add(coord); } SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName(typeName); b.setCRS(crs); b.add(THE_GEOM, LineString.class); b.add(LAYER, String.class); SimpleFeatureType type = b.buildFeatureType(); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); Geometry lineString = gF.createLineString(coordList.toCoordinateArray()); Object[] values = new Object[]{lineString, layerName}; builder.addAll(values); return builder.buildFeature(typeName + "." + id); }
Example #9
Source File: GeoUtils.java From elasticsearch-plugin-geoshape with MIT License | 4 votes |
public static LinearRing removeDuplicateCoordinates(LinearRing linearRing) { return linearRing.getFactory().createLinearRing( new CoordinateList(linearRing.getCoordinates(), false).toCoordinateArray() ); }
Example #10
Source File: GeometryGenerator.java From geowave with Apache License 2.0 | 4 votes |
/** * @param count * @param distanceactors * @param distortationFn * @param delta * @param env * @return */ public static Iterator<Geometry> generate( final int count, final List<Double> distanceactors, final DistortationFn distortationFn, final double delta, final Envelope env) { // Create the star-ellipses for intersections later on return new Iterator<Geometry>() { int currentCount = 0; GeometryFactory geometryFactory = new GeometryFactory(); @Override public boolean hasNext() { return currentCount < count; } @Override public Geometry next() { // Thanks to Chris Bennight for the foundations of this code. currentCount++; final double cx = env.centre().x * distortationFn.distort(); final double cy = env.centre().y * distortationFn.distort(); final double dx = env.getWidth() * distortationFn.distort(); final double dy = env.getHeight() * distortationFn.distort(); // We will use a coordinate list to build the linear ring final CoordinateList clist = new CoordinateList(); double angle = 0.0; for (int i = 0; angle < 360; angle += (delta * distortationFn.distort()) + delta, i++) { final double a = distanceactors.get(i % distanceactors.size()) * dx * distortationFn.distort(); // double b = distanceactors.get(i % distanceactors.size()) // * dy * distortationFn.distort(); clist.add( new Coordinate( cx + (a * Math.sin(Math.toRadians(angle))), cy + (a * Math.cos(Math.toRadians(angle))))); } clist.add(clist.get(0)); return geometryFactory.createPolygon(clist.toCoordinateArray()); } @Override public void remove() {} }; }