Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Point


    geometry = new LineString(new CoordinateArraySequence(coordinates), factory);
    return geometry;
  }

  private Point createPoint(GeometryFactory factory, JSONObject jso) throws UnmarshallException {
    Point geometry;
    JSONArray jsonCoords = jso.getJSONArray(ATTRIBUTE_COORDINATES);
    if (jsonCoords == null) {
      throw new UnmarshallException("coordinates missing");
    }
    if (jsonCoords.length() != 1) {
      throw new UnmarshallException("wrong number of coordinates " + jsonCoords.length() + " for point");
    }
    JSONObject coord = jsonCoords.getJSONObject(0);
    if (coord == null) {
      throw new UnmarshallException("inner coordinate missing");
    }

    Coordinate coordinate = new Coordinate(coord.getDouble("x"), coord.getDouble("y"));
    geometry = new Point(new CoordinateArraySequence(new Coordinate[] {coordinate}), factory);
    return geometry;
  }
View Full Code Here


    ArrayList<Point> jtsPoints = new ArrayList<Point>();
    for (VectorXZ p : points) {
      CoordinateSequence coordinateSequence =
        new CoordinateArraySequence(new Coordinate[] {
            vectorXZToJTSCoordinate(p)});
      jtsPoints.add(new Point(coordinateSequence, GF));
    }
   
    triangulationBuilder.setSites(
        new GeometryCollection(jtsPoints.toArray(EMPTY_GEOM_ARRAY), GF));
    triangulationBuilder.setConstraints(
View Full Code Here

  public void testSinglePointRoundTrip() throws SAXException, IOException, ParserConfigurationException{
    PointGenerator pg = new PointGenerator();
    pg.setGeometryFactory(geometryFactory);
    pg.setBoundingBox(new Envelope(0,10,0,10));
   
    Point pt = (Point) pg.create();

    GMLWriter out = new GMLWriter();
    out.setPrefix(null);
    out.write(pt,getWriter());
   
    GMLReader in = new GMLReader();
    Point pt2 = (Point) in.read(getReader(),geometryFactory);

//    System.out.println((pt==null?"NULL":pt.toString()));
//    System.out.println((pt2==null?"NULL":pt2.toString()));
    assertTrue("The input Point is not the same as the output Point",pt.equals(pt2));
  }
View Full Code Here

    }
    if(boundingBox == null || boundingBox.isNull()){
      throw new NullPointerException("Bounding Box is not declared");
    }
   
    Point p = geometryFactory.toGeometry(boundingBox).getCentroid();
    geometryFactory.getPrecisionModel().makePrecise(p.getCoordinate());
    return p;
  }
View Full Code Here

          Logger.info("Stops loaded: " + stopCount);
          Logger.info("GtfsImporter: importing Shapes...");
         
          Logger.info("Calculating agency centroid for stops...");
         
        Point centroid = Stop.findCentroid(primaryAgencyId);
        Logger.info("Center: " + centroid.getCoordinate().y + ", " + centroid.getCoordinate().x);
         
        primaryAgency.defaultLat = centroid.getCoordinate().y;
        primaryAgency.defaultLon = centroid.getCoordinate().x;
       
        primaryAgency.save();
       
          GtfsSnapshotMergeTask tripShapeTask = new GtfsSnapshotMergeTask(snapshotMerge);
          tripShapeTask.startTask();
View Full Code Here

              patternStops = TripPatternStop.find("pattern = ?", tripPattern).fetch();
             
              for(TripPatternStop patternStop : patternStops) {
               
               
                Point p = (Point) JTS.transform(patternStop.stop.locationPoint(), mt);
               
                LinearLocation l = indexLine.project(p.getCoordinate());
                patternStop.defaultDistance = LengthLocationMap.getLength(ls, l);
                patternStop.save();
              }
            }
           
View Full Code Here

     */
    public void showLocation( Object selection ){
        // selection should be an Feture (of some sort)
        SimpleFeature feature = (SimpleFeature) selection;
        Geometry geom = (Geometry) feature.getDefaultGeometry();
        Point point = geom.getCentroid();
       
        IMap imap = ApplicationGIS.getActiveMap();
        if( imap == ApplicationGIS.NO_MAP ) return;
       
        CoordinateReferenceSystem world = imap.getViewportModel().getCRS();
        CoordinateReferenceSystem wsg84 = DefaultGeographicCRS.WGS84;
       
        double buffer = 0.01; // how much of the wgs84 world to see
        Envelope view = point.buffer( buffer ).getEnvelopeInternal();
       
        MathTransform transform;
        try {
            transform = CRS.findMathTransform( wsg84, world, true ); // relaxed
        } catch (FactoryException e) {
View Full Code Here

        for( Edge edge : path ){
            Object obj = edge.getObject();
            Node start = edge.getNodeA();
            Node end = edge.getNodeB();
       
            Point startPoint = (Point) start.getObject();
            Point endPoint = (Point) end.getObject();           
            java.awt.Point startPixel = context.worldToPixel( startPoint.getCoordinate() );
            java.awt.Point endPixel = context.worldToPixel( endPoint.getCoordinate() );

            graphics.drawLine(startPixel.x, startPixel.y, endPixel.x, endPixel.y);           
        }
        graphics.setColor( Color.YELLOW );
        graphics.setLineWidth(2);
        for( Edge edge : path ){
            Object obj = edge.getObject();
            Node start = edge.getNodeA();
            Node end = edge.getNodeB();
       
            Point startPoint = (Point) start.getObject();
            Point endPoint = (Point) end.getObject();           
            java.awt.Point startPixel = context.worldToPixel( startPoint.getCoordinate() );
            java.awt.Point endPixel = context.worldToPixel( endPoint.getCoordinate() );

            graphics.drawLine(startPixel.x, startPixel.y, endPixel.x, endPixel.y);           
        }
        for( Node node : waypoints ){
            Point point = (Point) node.getObject();
            java.awt.Point pixel = context.worldToPixel( point.getCoordinate() );
           
            graphics.setColor( Color.YELLOW );               
            graphics.fillOval(pixel.x-3, pixel.y-3, 7, 7 );

            graphics.setColor( Color.BLACK );
View Full Code Here

            Coordinate worldLocation = new Coordinate();
           
            drawMonitor.beginTask("draw "+csv.toString(), csv.getSize());           
            String [] row;
            while ((row = reader.readNext()) != null) {
                Point point = csv.getPoint(row);
                Coordinate dataLocation = point.getCoordinate();
                try {
                    JTS.transform(dataLocation, worldLocation, dataToWorld);
                } catch (TransformException e) {
                    continue;
                }               
View Full Code Here

            monitor.subTask("drawing");
            int nameIndex = csv.getHeader("name");
            Coordinate worldLocation = new Coordinate();
            String [] row;
            while ((row = reader.readNext()) != null) {
                Point point = csv.getPoint(row);
                worldLocation = point.getCoordinate();
                if (bounds != null && !bounds.contains(worldLocation)) {
                    continue; // optimize!
                }
                java.awt.Point p = getContext().worldToPixel(worldLocation);
                g.fillOval(p.x, p.y, 10, 10);
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.