Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Point


  public void testDecline() throws Exception
  {
    LineString featureGeometry = this.geometryFactory.createLineString( LimbGeneratorTest.Utils.createCoords( "0 40, 40 0" ) );
    this.feature.setDefaultGeometry( featureGeometry );
   
    Point intersectionPoint = this.geometryFactory.createPoint( new Coordinate( 20, 20 ) );
   
    Limb limb = new Limb();
    limb.setFeature( this.feature );
    limb.setIntersection( intersectionPoint );
   
View Full Code Here


  public void testNegativeIncline() throws Exception
  {
    LineString featureGeometry = this.geometryFactory.createLineString( LimbGeneratorTest.Utils.createCoords( "40 0, 0 40" ) );
    this.feature.setDefaultGeometry( featureGeometry );
   
    Point intersectionPoint = this.geometryFactory.createPoint( new Coordinate( 20, 20 ) );
   
    Limb limb = new Limb();
    limb.setFeature( this.feature );
    limb.setIntersection( intersectionPoint );
   
View Full Code Here

  public void testNegativeDecline() throws Exception
  {
    LineString featureGeometry = this.geometryFactory.createLineString( LimbGeneratorTest.Utils.createCoords( "40 40, 0 0" ) );
    this.feature.setDefaultGeometry( featureGeometry );
   
    Point intersectionPoint = this.geometryFactory.createPoint( new Coordinate( 20, 20 ) );
   
    Limb limb = new Limb();
    limb.setFeature( this.feature );
    limb.setIntersection( intersectionPoint );
   
View Full Code Here

   * @param options processing options
   * @return the angle of the feature through the intersection point, in degrees
   */
  protected double calculateAngle( Geometry bufferedIntersection, Options options )
  {
    Point firstPoint = Geometries.getFirstPoint( bufferedIntersection );
    Point  lastPoint = Geometries.getLastPoint( bufferedIntersection );
   
    double xDelta = firstPoint.getX() - lastPoint.getX();
    double yDelta = firstPoint.getY() - lastPoint.getY();
   
    double angle;
    if (Math.abs( xDelta ) < Double.MIN_VALUE)
    {
      angle = (yDelta > 0) ? -90.0 : 90.0;
View Full Code Here

                .asString();
          //  String[] coordinateSplit = coordinate.split(",");
          //  lng = coordinateSplit[0];
          //  lat = coordinateSplit[1];
            WKTReader reader = new WKTReader();
            Point JTSPoint = (Point)reader.read(coordinate);
            if(JTSPoint == null) continue;
            lng = Double.toString(JTSPoint.getX());
            lat = Double.toString(JTSPoint.getY());
          } catch (Exception e) {
            logger.error("Error creating point! Skipping it.", e);
            continue;
          }
          break;
View Full Code Here

        e.printStackTrace();
      } catch (FactoryException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      Point p = (Point) SpatialReferenceSystemTransformationUtil
          .Transform((Geometry) pointFeature.getAttribute(GEOM),
              sourceCRS, targetCRS);
      /*
       * keep this for a while MathTransform transform=null; try {
       * transform = CRS.findMathTransform(sourceCRS, targetCRS,true); }
       * catch (FactoryException e) { // TODO Auto-generated catch block
       * e.printStackTrace(); } Point p=null; try { Point temp =
       * (Point)pointFeature.getAttribute("GEOM"); p =
       * (Point)JTS.transform( temp, transform); } catch
       * (MismatchedDimensionException e) { e.printStackTrace(); } catch
       * (TransformException e) { e.printStackTrace(); }
       */
      String label = getKMLLabel(pointFeature);
      String category = getKMLCategory(pointFeature);
      String htmlDescription = getHTMLDescription(pointFeature);
      String styleID = getKMLStyle(category, folder);
     
      folder.createAndAddPlacemark().withName(label)
          .withDescription(htmlDescription).withVisibility(true)
          .withStyleUrl("#" + styleID).createAndSetPoint()
          .withAltitudeMode(AltitudeMode.CLAMP_TO_GROUND)
          .addToCoordinates(p.getX() + "," + p.getY());
      featureCounter++;
      kmlLookAtX += p.getX();
      kmlLookAtY += p.getY();
    }
    for (SimpleFeature lineFeature : lineFeatureList) {
      String htmlDescription = getHTMLDescription(lineFeature);

      CoordinateReferenceSystem sourceCRS = lineFeature.getType()
View Full Code Here

        }
      }
      double max = xmax - xmin + ymax - ymin;

      // Extend start vertex
      Point ptStart = source.getStartPoint();
      Point ptStart2 = source.getPointN(1);
      // Calculate an extend point
      double aStart = Math.atan((ptStart2.getY() - ptStart.getY())
          / (ptStart2.getX() - ptStart.getX()));
      double xStart = ptStart.getX() + max
          * (ptStart2.getX() > ptStart.getX() ? -1 : 1)
          * Math.abs(Math.cos(aStart));
      double yStart = ptStart.getY() + max
          * (ptStart2.getY() > ptStart.getY() ? -1 : 1)
          * Math.abs(Math.sin(aStart));
      Point ptStart3 = GeometryUtil.gf().createPoint(
          new Coordinate(xStart, yStart));
      LineString lStart = GeometryUtil.gf().createLineString(
          new Coordinate[] { ptStart.getCoordinate(),
              ptStart3.getCoordinate() });

      Point nearestCrossStart = null;
      double nearestStart = Double.MAX_VALUE;
      for (Iterator<LineString> itrTrimExtend = trimExtendToList
          .iterator(); itrTrimExtend.hasNext();) {
        LineString l = itrTrimExtend.next();
        Geometry crossPoints = l.intersection(lStart);
        if (crossPoints != null) {
          ArrayList<Point> pts = new ArrayList<Point>();
          if (crossPoints instanceof Point) {
            pts.add((Point) crossPoints);
          } else if (crossPoints instanceof MultiPoint) {
            MultiPoint mp = (MultiPoint) crossPoints;
            for (int i = 0, count = mp.getNumGeometries(); i < count; i++) {
              Point pt = (Point) mp.getGeometryN(i);
              pts.add(pt);
            }
          }
          for (Iterator<Point> itr = pts.iterator(); itr.hasNext();) {
            Point pt = itr.next();
            double d = pt.distance(ptStart);
            if (d < nearestStart) {
              nearestStart = d;
              nearestCrossStart = pt;
            }
          }
        }
      }
      if (nearestCrossStart != null) {
        lineCoords.add(0, nearestCrossStart.getCoordinate());
      }

      // Extend end vertex
      Point ptEnd = source.getEndPoint();
      Point ptEnd2 = source.getPointN(source.getNumPoints() - 2);
      // Calculate an extend point
      double aEnd = Math.atan((ptEnd2.getY() - ptEnd.getY())
          / (ptEnd2.getX() - ptEnd.getX()));
      double xEnd = ptEnd.getX() + max
          * (ptEnd2.getX() > ptEnd.getX() ? -1 : 1)
          * Math.abs(Math.cos(aEnd));
      double yEnd = ptEnd.getY() + max
          * (ptEnd2.getY() > ptEnd.getY() ? -1 : 1)
          * Math.abs(Math.sin(aEnd));
      Point ptEnd3 = GeometryUtil.gf().createPoint(
          new Coordinate(xEnd, yEnd));
      LineString lEnd = GeometryUtil.gf().createLineString(
          new Coordinate[] { ptEnd.getCoordinate(),
              ptEnd3.getCoordinate() });

      Point nearestCrossEnd = null;
      double nearestEnd = Double.MAX_VALUE;
      for (Iterator<LineString> itrTrimExtend = trimExtendToList
          .iterator(); itrTrimExtend.hasNext();) {
        LineString l = itrTrimExtend.next();
        Geometry crossPoints = l.intersection(lEnd);
        if (crossPoints != null) {
          ArrayList<Point> pts = new ArrayList<Point>();
          if (crossPoints instanceof Point) {
            pts.add((Point) crossPoints);
          } else if (crossPoints instanceof MultiPoint) {
            MultiPoint mp = (MultiPoint) crossPoints;
            for (int i = 0, count = mp.getNumGeometries(); i < count; i++) {
              Point pt = (Point) mp.getGeometryN(i);
              pts.add(pt);
            }
          }
          for (Iterator<Point> itr = pts.iterator(); itr.hasNext();) {
            Point pt = itr.next();
            double d = pt.distance(ptEnd);
            if (d < nearestEnd) {
              nearestEnd = d;
              nearestCrossEnd = pt;
            }
          }
View Full Code Here

    JSONArray arrayTemp = null;
    JSONArray arrayTemp2 = null;

    // Point
    if (geometry.getClass().equals(Point.class)) {
      Point pt = (Point) geometry;
      obj.put("x", pt.getX());
      obj.put("y", pt.getY());
    }

    // LineString
    else if (geometry.getClass().equals(LineString.class)) {
      LineString ls = (LineString) geometry;
      Coordinate[] coords = ls.getCoordinates();
      arrayTemp = new JSONArray();
      for (int i = 0, count = coords.length; i < count; i++) {
        Coordinate coord = coords[i];
        arrayTemp2 = new JSONArray();
        arrayTemp2.put(coord.x);
        arrayTemp2.put(coord.y);
        arrayTemp.put(arrayTemp2);
      }
      arrayTemp2 = new JSONArray();
      arrayTemp2.put(arrayTemp);
      obj.put("paths", arrayTemp2);
    }

    // Polygon
    else if (geometry.getClass().equals(Polygon.class)) {
      Polygon pg = (Polygon) geometry;
      Coordinate[] coords = pg.getExteriorRing().getCoordinates();
      arrayTemp = new JSONArray();
      for (int i = 0, count = coords.length; i < count; i++) {
        Coordinate coord = coords[i];
        arrayTemp2 = new JSONArray();
        arrayTemp2.put(coord.x);
        arrayTemp2.put(coord.y);
        arrayTemp.put(arrayTemp2);
      }
      arrayTemp2 = new JSONArray();
      arrayTemp2.put(arrayTemp);
      obj.put("rings", arrayTemp2);
    }

    // MultiPoint
    else if (geometry.getClass().equals(MultiPoint.class)) {
      MultiPoint mpt = (MultiPoint) geometry;
      arrayTemp = new JSONArray();
      for (int i = 0, count = mpt.getNumGeometries(); i < count; i++) {
        Geometry geo = mpt.getGeometryN(i);
        if (geo.getClass().equals(Point.class)) {
          Point pt = (Point) geo;
          arrayTemp2 = new JSONArray();
          arrayTemp2.put(pt.getX());
          arrayTemp2.put(pt.getY());
          arrayTemp.put(arrayTemp2);
        }
      }
      obj.put("points", arrayTemp);
    }
View Full Code Here

    return result;
  }

  public static Point labelPoint(Geometry geometry) {
    Point result = null;

    try {
      result = geometry.getInteriorPoint();
    } catch (Exception e) {
      StringBuilder sb = new StringBuilder();
View Full Code Here

      obj.put("GIServerVersion", VersionUtil.getCurrentversion());
      if (polygons != null && points == null) {
        ArrayList<String> details = new ArrayList<String>();
        details.add("Result is NULL.");
      } else {
        Point pt = null;
        arrayTemp = new JSONArray();
        for (int i = 0; i < points.length; i++) {
          pt = points[i];
          objTemp = new JSONObject();
          objTemp.put("x", pt.getX());
          objTemp.put("y", pt.getY());
          arrayTemp.put(objTemp);
        }
        obj.put("labelPoints", arrayTemp);
      }
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.