test_class.declarator: OFFSET_X = 11000000
test_class.modifier: static final
test_class.original_string: static final int OFFSET_X = 11000000;
test_class.type: int
test_class.var_name: OFFSET_X
test_class.declarator: OFFSET_Y = 50000000
test_class.modifier: static final
test_class.original_string: static final int OFFSET_Y = 50000000;
test_class.type: int
test_class.var_name: OFFSET_Y
test_class.declarator: polygon
test_class.modifier: static
test_class.original_string: static OsmNogoPolygon polygon;
test_class.type: OsmNogoPolygon
test_class.var_name: polygon
test_class.declarator: polyline
test_class.modifier: static
test_class.original_string: static OsmNogoPolygon polyline;
test_class.type: OsmNogoPolygon
test_class.var_name: polyline
test_class.declarator: lons = {  1.0,  1.0,  0.5, 0.5, 1.0, 1.0, -1.1, -1.0 }
test_class.modifier: static final
test_class.original_string: static final double[] lons = {  1.0,  1.0,  0.5, 0.5, 1.0, 1.0, -1.1, -1.0 };
test_class.type: double[]
test_class.var_name: lons
test_class.declarator: lats = { -1.0, -0.1, -0.1, 0.1, 0.1, 1.0,  1.1, -1.0 }
test_class.modifier: static final
test_class.original_string: static final double[] lats = { -1.0, -0.1, -0.1, 0.1, 0.1, 1.0,  1.1, -1.0 };
test_class.type: double[]
test_class.var_name: lats
test_class.file: brouter-core/src/test/java/btools/router/OsmNogoPolygonTest.java
test_class.identifier: OsmNogoPolygonTest
test_case.body: @Test
    public void testCalcBoundingCircle() {
      double[] lonlat2m = CheapRuler.getLonLatToMeterScales( polygon.ilat );
      double dlon2m = lonlat2m[0];
      double dlat2m = lonlat2m[1];
  
      polygon.calcBoundingCircle();
      double r = polygon.radius;
      for (int i=0; i<lons.length; i++) {
        double dpx = (toOsmLon(lons[i], OFFSET_X) - polygon.ilon) * dlon2m;
        double dpy = (toOsmLat(lats[i], OFFSET_Y) - polygon.ilat) * dlat2m;
        double r1 = Math.sqrt(dpx * dpx + dpy * dpy);
        double diff = r-r1;
        assertTrue("i: "+i+" r("+r+") >= r1("+r1+")", diff >= 0);
      }
      polyline.calcBoundingCircle();
      r = polyline.radius;
      for (int i=0; i<lons.length; i++) {
        double dpx = (toOsmLon(lons[i], OFFSET_X) - polyline.ilon) * dlon2m;
        double dpy = (toOsmLat(lats[i], OFFSET_Y) - polyline.ilat) * dlat2m;
        double r1 = Math.sqrt(dpx * dpx + dpy * dpy);
        double diff = r-r1;
        assertTrue("i: "+i+" r("+r+") >= r1("+r1+")", diff >= 0);
      }
    }
test_case.class_method_signature: OsmNogoPolygonTest.testCalcBoundingCircle()
test_case.full_signature: @Test public void testCalcBoundingCircle()
test_case.identifier: testCalcBoundingCircle
test_case.invocations: getLonLatToMeterScales calcBoundingCircle toOsmLon toOsmLat sqrt assertTrue calcBoundingCircle toOsmLon toOsmLat sqrt assertTrue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCalcBoundingCircle()
focal_class.declarator: points = new ArrayList<Point>()
focal_class.modifier: public final
focal_class.original_string: public final List<Point> points = new ArrayList<Point>();
focal_class.type: List<Point>
focal_class.var_name: points
focal_class.declarator: isClosed
focal_class.modifier: public final
focal_class.original_string: public final boolean isClosed;
focal_class.type: boolean
focal_class.var_name: isClosed
focal_class.file: brouter-core/src/main/java/btools/router/OsmNogoPolygon.java
focal_class.identifier: OsmNogoPolygon
focal_class.class_method_signature: OsmNogoPolygon.OsmNogoPolygon(boolean closed)
focal_class.full_signature: public  OsmNogoPolygon(boolean closed)
focal_class.identifier: OsmNogoPolygon
focal_class.modifiers: public
focal_class.parameters: (boolean closed)
focal_class.signature:  OsmNogoPolygon(boolean closed)
focal_class.class_method_signature: OsmNogoPolygon.addVertex(int lon, int lat)
focal_class.full_signature: public final void addVertex(int lon, int lat)
focal_class.identifier: addVertex
focal_class.modifiers: public final
focal_class.parameters: (int lon, int lat)
focal_class.return: void
focal_class.signature: void addVertex(int lon, int lat)
focal_class.class_method_signature: OsmNogoPolygon.calcBoundingCircle()
focal_class.full_signature: public void calcBoundingCircle()
focal_class.identifier: calcBoundingCircle
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void calcBoundingCircle()
focal_class.class_method_signature: OsmNogoPolygon.intersects(int lon0, int lat0, int lon1, int lat1)
focal_class.full_signature: public boolean intersects(int lon0, int lat0, int lon1, int lat1)
focal_class.identifier: intersects
focal_class.modifiers: public
focal_class.parameters: (int lon0, int lat0, int lon1, int lat1)
focal_class.return: boolean
focal_class.signature: boolean intersects(int lon0, int lat0, int lon1, int lat1)
focal_class.class_method_signature: OsmNogoPolygon.isOnPolyline( long px, long py )
focal_class.full_signature: public boolean isOnPolyline( long px, long py )
focal_class.identifier: isOnPolyline
focal_class.modifiers: public
focal_class.parameters: ( long px, long py )
focal_class.return: boolean
focal_class.signature: boolean isOnPolyline( long px, long py )
focal_class.class_method_signature: OsmNogoPolygon.isOnLine( long px, long py, long p0x, long p0y, long p1x, long p1y )
focal_class.full_signature: public static boolean isOnLine( long px, long py, long p0x, long p0y, long p1x, long p1y )
focal_class.identifier: isOnLine
focal_class.modifiers: public static
focal_class.parameters: ( long px, long py, long p0x, long p0y, long p1x, long p1y )
focal_class.return: boolean
focal_class.signature: boolean isOnLine( long px, long py, long p0x, long p0y, long p1x, long p1y )
focal_class.class_method_signature: OsmNogoPolygon.isWithin(final long px, final long py)
focal_class.full_signature: public boolean isWithin(final long px, final long py)
focal_class.identifier: isWithin
focal_class.modifiers: public
focal_class.parameters: (final long px, final long py)
focal_class.return: boolean
focal_class.signature: boolean isWithin(final long px, final long py)
focal_class.class_method_signature: OsmNogoPolygon.distanceWithinPolygon(int lon1, int lat1, int lon2, int lat2)
focal_class.full_signature: public double distanceWithinPolygon(int lon1, int lat1, int lon2, int lat2)
focal_class.identifier: distanceWithinPolygon
focal_class.modifiers: public
focal_class.parameters: (int lon1, int lat1, int lon2, int lat2)
focal_class.return: double
focal_class.signature: double distanceWithinPolygon(int lon1, int lat1, int lon2, int lat2)
focal_class.class_method_signature: OsmNogoPolygon.inSegment( final Point p, final Point seg_p0, final Point seg_p1)
focal_class.full_signature: private static boolean inSegment( final Point p, final Point seg_p0, final Point seg_p1)
focal_class.identifier: inSegment
focal_class.modifiers: private static
focal_class.parameters: ( final Point p, final Point seg_p0, final Point seg_p1)
focal_class.return: boolean
focal_class.signature: boolean inSegment( final Point p, final Point seg_p0, final Point seg_p1)
focal_class.class_method_signature: OsmNogoPolygon.intersect2D_2Segments( final Point s1p0, final Point s1p1, final Point s2p0, final Point s2p1 )
focal_class.full_signature: private static int intersect2D_2Segments( final Point s1p0, final Point s1p1, final Point s2p0, final Point s2p1 )
focal_class.identifier: intersect2D_2Segments
focal_class.modifiers: private static
focal_class.parameters: ( final Point s1p0, final Point s1p1, final Point s2p0, final Point s2p1 )
focal_class.return: int
focal_class.signature: int intersect2D_2Segments( final Point s1p0, final Point s1p1, final Point s2p0, final Point s2p1 )
focal_class.superclass: extends OsmNodeNamed
focal_method.body: public void calcBoundingCircle()
    {
      int cxmin, cxmax, cymin, cymax;
      cxmin = cymin = Integer.MAX_VALUE;
      cxmax = cymax = Integer.MIN_VALUE;
  
      // first calculate a starting center point as center of boundingbox
      for (int i = 0; i < points.size(); i++)
      {
        final Point p = points.get(i);
        if (p.x < cxmin)
        {
          cxmin = p.x;
        }
        if (p.x > cxmax)
        {
          cxmax = p.x;
        }
        if (p.y < cymin)
        {
          cymin = p.y;
        }
        if (p.y > cymax)
        {
          cymax = p.y;
        }
      }
  
      int cx = (cxmax+cxmin) / 2; // center of circle
      int cy = (cymax+cymin) / 2;
  
      double[] lonlat2m = CheapRuler.getLonLatToMeterScales( cy );
      double dlon2m = lonlat2m[0];
      double dlat2m = lonlat2m[1];
  
      double rad = 0;  // radius
  
      double dmax = 0; // length of vector from center to point
      int i_max = -1;
  
      do
      {
        // now identify the point outside of the circle that has the greatest distance
        for (int i = 0; i < points.size(); i++)
        {
          final Point p = points.get(i);
          final double dist = CheapRuler.distance(p.x, p.y, (int) cx, (int) cy);
          if (dist <= rad)
          {
            continue;
          }
          if (dist > dmax)
          {
            // new maximum distance found
            dmax = dist;
            i_max = i;
          }
        }
        if (i_max < 0)
        {
      	  break; // leave loop when no point outside the circle is found any more.
        }
        final double dd = 0.5 * (1 - rad / dmax);
  
        final Point p = points.get(i_max); // calculate new radius to just include this point
        cx += (int)(dd * (p.x - cx) + 0.5); // shift center toward point
        cy += (int)(dd * (p.y - cy) + 0.5);
  
        dmax = rad = CheapRuler.distance(p.x, p.y, (int) cx, (int) cy);
        i_max = -1;
      }
      while (true);
  
      ilon = cx;
      ilat = cy;
      radius = rad;
      return;
    }
focal_method.class_method_signature: OsmNogoPolygon.calcBoundingCircle()
focal_method.full_signature: public void calcBoundingCircle()
focal_method.identifier: calcBoundingCircle
focal_method.invocations: size get getLonLatToMeterScales size get distance get distance
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void calcBoundingCircle()