Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Point


        if (geometryType != MULTIGEOMETRY) {
            this.key("coordinates");

            switch (geometryType) {
            case POINT:
                Point point = (Point)geometry;
                writeCoordinate(point.getX(), point.getY());
                break;
            case LINESTRING:
                writeCoordinates(((LineString)geometry).getCoordinateSequence());
                break;
            case MULTIPOINT:
View Full Code Here


                        tx = CRS.findMathTransform(nativeCRS, WGS84);
                    }
                }

                // see if the features is to be included in this tile
                Point p = ((Geometry) f.getDefaultGeometry()).getCentroid();
                coords[0] = p.getX();
                coords[1] = p.getY();
                if (tx != null)
                    tx.transform(coords, 0, coords, 0, 1);
                if (tile.contains(coords[0], coords[1]))
                    currFids.add(f.getID());
            }
View Full Code Here

         * @param geom DOCUMENT ME!
         *
         * @throws IOException DOCUMENT ME!
         */
        protected void writeGeometry(Geometry geom) throws IOException {
            Point p = (Point) geom;

            if (pointsAsCircles) {
                write(" cx=\"");
                write(getX(p.getX()));
                write("\" cy=\"");
                write(getY(p.getY()));
            } else {
                write(" x=\"");
                write(getX(p.getX()));
                write("\" y=\"");
                write(getY(p.getY()));
                //Issue GEOS-193, from John Steining.
                write("\" xlink:href=\"#point");

                //putting this in to fix the issue, but I am not sure about
                //the broader implications - I don't think we need it for
View Full Code Here

        return new OneTimeTestSetup(new SVGMapProducerTest());
    }
   
    public void testHeterogeneousGeometry() throws Exception {
        GeometryFactory gf = new GeometryFactory();
        Point point = gf.createPoint(new Coordinate(10, 10));
        LineString line = gf.createLineString(new Coordinate[] {
                new Coordinate(50, 50), new Coordinate(100, 100) });
        Polygon polygon = gf.createPolygon(gf
                .createLinearRing(new Coordinate[] { new Coordinate(0, 0),
                        new Coordinate(0, 200), new Coordinate(200, 200),
View Full Code Here

            fi = fs.getFeatures(q).features();
            while (fi.hasNext()) {
                // grab the centroid and transform it in 4326 if necessary
                SimpleFeature f = (SimpleFeature) fi.next();
                Geometry g = (Geometry) f.getDefaultGeometry();
                Point centroid = g.getCentroid();
               
                //robustness check for bad geometries
                if ( Double.isNaN( centroid.getX() ) || Double.isNaN( centroid.getY() ) ) {
                    LOGGER.warning( "Could not calculate centroid for feature " + f.getID() + "; g =  " + g.toText() );
                    continue;
                }
               
                coords[0] = centroid.getX();
                coords[1] = centroid.getY();
                if (tx != null)
                    tx.transform(coords, 0, coords, 0, 1);

                // insert
                ps.setDouble(1, coords[0]);
View Full Code Here

         * @param geom point to encode
         *
         * @throws IOException if an error occures during encoding
         */
        protected void writeGeometry(Geometry geom,StringBuffer buf) throws IOException {
            Point p = (Point) geom;
            if(asCircle) {
              writeToBuffer(getPoint(p.getCoordinate())+","+(int)Math.round(size),buf);
            } else{
              throw new IOException("Nothing to encode");
              //TODO: manage different shapes
            }

View Full Code Here

        } else if (geom instanceof LineString) {
            LineString l = (LineString) geom;
            Coordinate[] coords = l.getCoordinates();
            writePolylineGeometry(layer, ownerHandle, coords, false);
        } else if (geom instanceof Point) {
            Point p = (Point) geom;
            writePointGeometry(layer, ownerHandle, p);
        }
    }
View Full Code Here

        for (Coordinate coord : targetPolygon.getCoordinates()) {
            polygonBuffer.append(coord.x).append(" ");
            polygonBuffer.append(coord.y).append(" ");
        }
        String targetPolygonCoords = polygonBuffer.toString().trim();
        Point targetPoint = (Point) JTS.transform(
                factory.createPoint(new Coordinate(42.58, 31.29)), transform);
        String targetPointCoord = targetPoint.getCoordinate().x + " "
                + targetPoint.getCoordinate().y;

        Document doc = getAsDOM("wfs?request=GetFeature&typename=ex:geomContainer&srsname=urn:x-ogc:def:crs:EPSG::4326");
        LOGGER
                .info("WFS GetFeature&typename=ex:geomContainer&srsname=urn:x-ogc:def:crs:EPSG::4326 response:\n"
                        + prettyString(doc));
View Full Code Here

    }

    public Point marshal(String v) {
        WKTReader fromText = new WKTReader();
        Geometry geom = null;
        Point p = null;
        try {
         geom = (Point) fromText.read(wktPoint);
        } catch (ParseException pe) {
            throw new RuntimeException("Not a WKT string" + wktPoint);
        }
View Full Code Here

            String gpsTaggingTolerance = r.getString(14);
           
            // convert a linestring to a JTS geometry
            WKTReader reader = new WKTReader();
            Geometry geometry = reader.read(lineString);
            Point centroidJTS = geometry.getCentroid();
           
            fetched = new StudyRegion();
            fetched.setId(id);
            fetched.setName(name);
            fetched.setDescription(description);
            fetched.setCurrentRegion(currentRegion);
            fetched.setMapZoomLevel(mapZoomLevel);
            fetched.setDefaultZoneType(defaultZoneType);
            fetched.setUtcOffset(utcOffset);
            fetched.setMinimumSoakInterval(minimumSoakInterval);
            fetched.setCommercialZoneBlockLength(commercialZoneBlockLength);
            fetched.setIndustrialZoneBlockLength(industrialZoneBlockLength);
            fetched.setResidentialZoneBlockLength(residentialZoneBlockLength);
            fetched.setGpsTaggingTolerance(gpsTaggingTolerance);
           
            // now convert the geometry to an ArrayList<Vertex> and
            // set in the roadDetails
            ArrayList<Vertex> vertices = Utils.geometryToVertexArrayList(geometry);
            fetched.setVertices(vertices);
           
            // convert the centroid point into a Vertex
            Vertex centroid = new Vertex();
            centroid.setLat(centroidJTS.getY());
            centroid.setLng(centroidJTS.getX());
            fetched.setCentroid(centroid);
           
            // and get the map meta data too
            Geometry mapCenterGeom = reader.read(mapCenterWKT);
            Point mapCenterJTS = mapCenterGeom.getCentroid();
            Vertex mapCenterVertex = new Vertex();
            mapCenterVertex.setLat(mapCenterJTS.getY());
            mapCenterVertex.setLng(mapCenterJTS.getX());
            fetched.setMapCenter(mapCenterVertex);
      }
    } catch (SQLException e) {
      logger.error(e.getMessage());
      throw e;
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.Point

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.