Search in sources :

Example 1 with SweepLineInterval

use of com.vividsolutions.jts.index.sweepline.SweepLineInterval in project activityinfo by bedatadriven.

the class BatchGeocoder method geocode.

public List<List<AdminEntity>> geocode() {
    entities = queryEntities();
    // add the entities to the sweep line index
    indexEntities();
    index.computeOverlaps(new SweepLineOverlapAction() {

        @Override
        public void overlap(SweepLineInterval s0, SweepLineInterval s1) {
            // is this an overlap between a point and and entity?
            if (s0.getItem() instanceof Integer && s1.getItem() instanceof AdminEntity) {
                checkContains((Integer) s0.getItem(), (AdminEntity) s1.getItem());
            } else if (s1.getItem() instanceof Integer && s0.getItem() instanceof AdminEntity) {
                checkContains((Integer) s1.getItem(), (AdminEntity) s0.getItem());
            }
        }
    });
    return results;
}
Also used : AdminEntity(org.activityinfo.server.database.hibernate.entity.AdminEntity) SweepLineOverlapAction(com.vividsolutions.jts.index.sweepline.SweepLineOverlapAction) SweepLineInterval(com.vividsolutions.jts.index.sweepline.SweepLineInterval)

Example 2 with SweepLineInterval

use of com.vividsolutions.jts.index.sweepline.SweepLineInterval in project activityinfo by bedatadriven.

the class BatchGeocoder method addPoint.

public void addPoint(double x, double y) {
    int pointIndex = points.size();
    // add the point to the list
    points.add(gf.createPoint(new Coordinate(x, y)));
    // index the point
    index.add(new SweepLineInterval(x, x, pointIndex));
    // add an empty result
    results.add(new ArrayList<AdminEntity>());
}
Also used : AdminEntity(org.activityinfo.server.database.hibernate.entity.AdminEntity) Coordinate(com.vividsolutions.jts.geom.Coordinate) SweepLineInterval(com.vividsolutions.jts.index.sweepline.SweepLineInterval) Point(com.vividsolutions.jts.geom.Point)

Aggregations

SweepLineInterval (com.vividsolutions.jts.index.sweepline.SweepLineInterval)2 AdminEntity (org.activityinfo.server.database.hibernate.entity.AdminEntity)2 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 Point (com.vividsolutions.jts.geom.Point)1 SweepLineOverlapAction (com.vividsolutions.jts.index.sweepline.SweepLineOverlapAction)1