Print

Print


Dear all,

I'm trying to identify geometry interceptions using the methods referred in
the subject. Running the class below I get the following output:

Objects covered by location: 1
Objects covering location: 0

Since the geometry is always the same I would expect these two methods to
have the same result, why are they different?

Any other simply way of checking if two geometries intersect?

Thank you.

Luís


import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;

import sim.field.geo.GeomVectorField;
import sim.util.Bag;
import sim.util.geo.MasonGeometry;

public class IntersectTest {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        GeomVectorField field = new GeomVectorField();
        GeometryFactory geomFactory = new GeometryFactory();
        Coordinate coord = new Coordinate(1, 1);
        MasonGeometry geom = new
MasonGeometry(geomFactory.createPoint(coord));
        field.addGeometry(geom);

        Bag covered = field.getCoveredObjects(geom);
        Bag covering = field.getCoveringObjects(geom);

        System.out.println("Objects covered by location: " +
covered.numObjs);
        System.out.println("Objects covering location: " +
covering.numObjs);
    }
}