[OpenMap Users] BoundaryCrossing iterator order

From: Paul Chisholm <pch42_at_tpg.com.au>
Date: Fri, 11 Sep 2009 20:28:10 +1000

Hi,

I am using the BoundaryCrossing feature of OpenMap to determine the
polygons that a path crosses. According to the API the
BoundaryCrossing.Collector.compact method is "An important method that
cleans up the segment/region BoundaryCrossing order, and also resolves
the BoundaryCrossing.in/out settings for regions. Must be called
before the crossing iterator is retrieved, but the BoundaryCrossing
method does that." The BoundaryCrossing.Collector.getCrossings method
calls "compact" before generating the iterator. However, I seem to get
strange results. When I run the following program

import com.bbn.openmap.geo.*;
import java.util.*;

public class Test {
     public static void main(String[] args) {
         List<GeoRegion> regions = new ArrayList();
         GeoRegion.Impl x = new GeoRegion.Impl(new float[]{10, 10,
-10, 10, -10, 20, 10, 20, 10, 10});
         x.setID("A");
         regions.add(x);
         GeoRegion.Impl y = new GeoRegion.Impl(new float[]{10, 30,
-10, 30, -10, 40, 10, 40, 10, 30});
         y.setID("B");
         regions.add(y);
         float[] route = {0, 0, 0, 25, 0, 50}; /
*****************************/
         GeoPath.Impl path = new GeoPath.Impl(route);
         BoundaryCrossing.Collector bcc =
BoundaryCrossing.getCrossings(path, regions);
         Iterator it = bcc.getCrossings();
         while (it.hasNext()) {
             BoundaryCrossing o = (BoundaryCrossing) it.next();
             GeoRegion in = o.getIn();
             GeoRegion ou = o.getOut();
             System.out.println(o.getGeo());
             if (in != null) {
                 System.out.println(" Enter " + in.getID());
             }
             if (ou != null) {
                 System.out.println(" Exit " + ou.getID());
             }
         }
     }
}

I get the output

Geo[-0.0,29.999999612082494]
     Enter B
Geo[-0.0,9.999999573437877]
     Enter A
Geo[-0.0,19.999999678147237]
     Exit A
Geo[-0.0,40.00000052659251]
     Exit B

The points I understand, but I expected them to appear in order Enter
A, Exit A, Enter B, Exit B

When I replace the line labelled

     /*****************/

with

     float[] route = {0, 50, 0, 25, 0, 0};

i.e. reverse the direction of the path, the output is

Geo[0.0,19.999999678147237]
     Enter A
Geo[0.0,9.999999573437877]
     Exit A
Geo[0.0,40.00000052659251]
     Enter B
Geo[0.0,29.999999612082494]
     Exit B

Is my understanding of the order in which the iterator returns
crossing points incorrect? If so, is there any way to order the
crossings in the sequence they are visited along the direction of the
path.

Thanks,
Paul

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Fri Sep 11 2009 - 06:29:20 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:09 EDT