Package org.apache.sis.geometry

Examples of org.apache.sis.geometry.DirectPosition2D


   *         circular region
   */
  public DirectPosition2D[] getCircularRegionApproximation(int numberOfPoints) {
    if (radius >= DistanceUtils.HALF_EARTH_CIRCUMFERENCE) {
      DirectPosition2D[] points = new DirectPosition2D[5];
      points[0] = new DirectPosition2D(-180.0, -90.0);
      points[1] = new DirectPosition2D(-180.0, 90.0);
      points[2] = new DirectPosition2D(180.0, 90.0);
      points[3] = new DirectPosition2D(180.0, -90.0);
      points[4] = points[0];
      return points;
    }
    // plus one to add closing point
    DirectPosition2D[] points = new DirectPosition2D[numberOfPoints + 1];
View Full Code Here


      return new Rectangle2D.Double(0.0, 0.0, 360.0, 180.0);
    }
    int numberOfCrossOvers = 0;

    Path2D path = new Path2D.Double();
    DirectPosition2D initPT = DistanceUtils.getPointOnGreatCircle(center.getOrdinate(1),
        center.getOrdinate(0), radius, 0);
    path.moveTo(initPT.x + 180.0, initPT.y + 90.0);

    DirectPosition2D currPT = initPT;

    for (int i = 1; i < 360; i++) {

      DirectPosition2D pt = DistanceUtils.getPointOnGreatCircle(center.getOrdinate(1),
          center.getOrdinate(0), radius, i);
      path.lineTo(pt.x + 180.0, pt.y + 90.0);

      if (dateLineCrossOver(Longitude.normalize(currPT.x), Longitude.normalize(pt.x))) {
        numberOfCrossOvers++;
View Full Code Here

    double lat2 = Math.asin((sinLat * cosD) + (cosLat * sinD * Math.cos(brng)));
    double lon2 = lon1
        + Math.atan2(Math.sin(brng) * sinD * cosLat, cosD - sinLat
            * Math.sin(lat2));

    return new DirectPosition2D(Math.toDegrees(lat2), Math.toDegrees(lon2));
  }
View Full Code Here

   * Tests the LatLonPointRadius constructor.
   */
  @Test
  public void testCreateLatLonPointRadius()
  {
    LatLonPointRadius region = new LatLonPointRadius(new DirectPosition2D(0.0, 0.0), 100.0);
    assertNotNull(region);
  }
View Full Code Here

   * Tests the getCircularRegionApproximation() method.
   */
  @Test
  public void testGetCircularRegionApproximation()
  {
    LatLonPointRadius pr1 = new LatLonPointRadius(new DirectPosition2D(0.0, 0.0), 25000.0);
    DirectPosition2D pts1[] = pr1.getCircularRegionApproximation(10);
    assertEquals(5, pts1.length);
    assertEquals(-90.0, pts1[0].y, EPSILON);
    assertEquals(-180.0, pts1[0].x, EPSILON);
    assertEquals(90.0, pts1[1].y, EPSILON);
    assertEquals(-180.0, pts1[1].x, EPSILON);
    assertEquals(90.0, pts1[2].y, EPSILON);
    assertEquals(180.0, pts1[2].x, EPSILON);
    assertEquals(-90.0, pts1[3].y, EPSILON);
    assertEquals(180.0, pts1[3].x, EPSILON);
    assertEquals(-90.0, pts1[4].y, EPSILON);
    assertEquals(-180.0, pts1[4].x, EPSILON);

    LatLonPointRadius pr2 = new LatLonPointRadius(new DirectPosition2D(0.0, 0.0), 1000.0);
    DirectPosition2D pts2[] = pr2.getCircularRegionApproximation(6);
    assertEquals(7, pts2.length);
  }
View Full Code Here

   * Tests the getRectangularRegionApproximation() method.
   */
  @Test
  public void testGetRectangularRegionApproximation()
  {
    LatLonPointRadius pr1 = new LatLonPointRadius(new DirectPosition2D(0.0, 0.0), 25000.0);
    Rectangle2D r1 = pr1.getRectangularRegionApproximation(10);
    assertEquals(0.0, r1.getX(), EPSILON);
    assertEquals(0.0, r1.getY(), EPSILON);
    assertEquals(360.0, r1.getWidth(), EPSILON);
    assertEquals(180.0, r1.getHeight(), EPSILON);
View Full Code Here

          for (int i = 4; i < tokens.length; i++) {
            String[] dataTokens = tokens[i].split(";");
            double lat = Double.parseDouble(dataTokens[0]);
            double lon = Double.parseDouble(dataTokens[1]);
            parent.getChild(quadrant).addData(
                new GeoRSSData(dataTokens[2], new DirectPosition2D(lon, lat)));
            tree.setSize(tree.getSize() + 1);
          }
          tree.setNodeSize(tree.getNodeSize() + 1);
        }
View Full Code Here

                if (item.getGuid() != null)
                  filename = cleanStr(item.getGuid().getValue()) + ".txt";
                else
                  filename = cleanStr(item.getLink()) + ".txt";

                GeoRSSData data = new GeoRSSData(filename, new DirectPosition2D(
                    geoRSSModule.getPosition().getLongitude(),
                    geoRSSModule.getPosition().getLatitude()));
                if (this.tree.insert(data)) {
                  data.saveToFile(item, geoRSSModule, georssStoragePath);
                } else {
View Full Code Here

      String urLat = request.getParameter("urLat");
      String urLon = request.getParameter("urLon");

      if (llLat != null && llLon != null && urLat != null && urLon != null) {
        try {
          Envelope2D bbox = new Envelope2D(new DirectPosition2D(
              Double.parseDouble(llLon), Double.parseDouble(llLat)),
              new DirectPosition2D(Double.parseDouble(urLon), Double.parseDouble(urLat)));

          beforeTime = System.currentTimeMillis();
          results = tree.queryByBoundingBox(bbox);
          afterTime = System.currentTimeMillis();
          // get the polygon that approximates the region
          Rectangle2D[] rects = bbox.toRectangles();
          for (int i = 0; i < rects.length; i++) {
            final Rectangle2D r = rects[i];
            String regionStr = (r.getMinY()) + "," + (r.getMinX()) + ",";
            regionStr += (r.getMaxY()) + "," + (r.getMinX()) + ",";
            regionStr += (r.getMaxY()) + "," + (r.getMaxX()) + ",";
            regionStr += (r.getMinY()) + "," + (r.getMaxX()) + ",";
            regionStr += (r.getMinY()) + "," + (r.getMinX());
            regions.add(regionStr);
          }
        } catch (NumberFormatException ex) {
          System.out
              .println("[ERROR] Input parameters were not valid latitudes and longitudes");
        }

      }
    } else if (type != null && type.equals("pointradius")) {
      String radius = request.getParameter("radius");
      String lat = request.getParameter("lat");
      String lon = request.getParameter("lon");

      if (radius != null && lat != null && lon != null) {

        DirectPosition2D point = null;
        try {
          point = new DirectPosition2D(Double.parseDouble(lon), Double.parseDouble(lat));
        } catch (NumberFormatException ex) {
          System.out
              .println("{ERROR] Input parameters were not valid latitudes and longitudes");
        }

        double radiusKM = Double.parseDouble(radius);

        String regionStr = "";

        for (int i = 0; i < 360; i += 10) {
          DirectPosition2D pt = DistanceUtils.getPointOnGreatCircle(point.y, point.x, radiusKM, i);
          regionStr += pt.y + "," + pt.x + ",";
        }
        DirectPosition2D pt = DistanceUtils.getPointOnGreatCircle(point.y, point.x, radiusKM, 0);
        regionStr += pt.y + "," + pt.x + ",";
        regions.add(regionStr.substring(0, regionStr.length() - 1));

        beforeTime = System.currentTimeMillis();
        results = tree.queryByPointRadius(point, radiusKM);
View Full Code Here

        if (isNaN(λ1) || isNaN(φ1) || isNaN(λ2) || isNaN(φ2)) {
            return NaN;
        }
        // Other cases: no solution for this algorithm.
        throw new ArithmeticException(Errors.format(Errors.Keys.NoConvergenceForPoints_2,
                  new DirectPosition2D(toDegrees(λ1), toDegrees(φ1)),
                  new DirectPosition2D(toDegrees(λ2), toDegrees(φ2))));
    }
View Full Code Here

TOP

Related Classes of org.apache.sis.geometry.DirectPosition2D

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.