Search in sources :

Example 1 with OsmDocument

use of com.revolsys.record.io.format.openstreetmap.model.OsmDocument in project com.revolsys.open by revolsys.

the class OpenStreetMapApiLayer method getTile.

private synchronized OsmDocument getTile(final BoundingBox boundingBox) {
    OsmDocument document = this.boundingBoxTileMap.get(boundingBox);
    if (document == null) {
        document = OsmDocument.newDocument(this.serverUrl, boundingBox);
        this.boundingBoxTileMap.put(boundingBox, document);
    }
    return document;
}
Also used : OsmDocument(com.revolsys.record.io.format.openstreetmap.model.OsmDocument)

Example 2 with OsmDocument

use of com.revolsys.record.io.format.openstreetmap.model.OsmDocument in project com.revolsys.open by revolsys.

the class OsmOverpassLayer method getRecords.

@Override
public List<LayerRecord> getRecords(BoundingBox boundingBox) {
    if (hasGeometryField()) {
        boundingBox = convertBoundingBox(boundingBox);
        if (Property.hasValue(boundingBox)) {
            final Map<Identifier, LayerRecord> recordMap = new HashMap<>();
            final List<BoundingBox> boundingBoxes = getTileBoundingBoxes(boundingBox);
            for (final BoundingBox tileBoundingBox : boundingBoxes) {
                final OsmDocument document = getTile(tileBoundingBox);
                for (final OsmElement record : document.getRecords()) {
                    final Geometry geometry = record.getGeometry();
                    if (geometry != null && !geometry.isEmpty()) {
                        if (boundingBox.intersects(geometry.getBoundingBox())) {
                            final Identifier identifier = record.getIdentifier();
                        // final OsmProxyLayerRecord layerRecord = new
                        // OsmProxyLayerRecord(
                        // this, document, identifier);
                        // recordMap.put(identifier, layerRecord);
                        }
                    }
                }
            }
            this.boundingBoxTileMap.keySet().retainAll(boundingBoxes);
            return new ArrayList<>(recordMap.values());
        }
    }
    return Collections.emptyList();
}
Also used : OsmElement(com.revolsys.record.io.format.openstreetmap.model.OsmElement) Geometry(com.revolsys.geometry.model.Geometry) Identifier(com.revolsys.identifier.Identifier) HashMap(java.util.HashMap) BoundingBox(com.revolsys.geometry.model.BoundingBox) ArrayList(java.util.ArrayList) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) OsmDocument(com.revolsys.record.io.format.openstreetmap.model.OsmDocument)

Example 3 with OsmDocument

use of com.revolsys.record.io.format.openstreetmap.model.OsmDocument in project com.revolsys.open by revolsys.

the class OsmOverpassLayer method getTile.

private synchronized OsmDocument getTile(final BoundingBox boundingBox) {
    OsmDocument document = this.boundingBoxTileMap.get(boundingBox);
    if (document == null) {
        document = OsmDocument.newDocument(this.serverUrl, boundingBox);
        this.boundingBoxTileMap.put(boundingBox, document);
    }
    return document;
}
Also used : OsmDocument(com.revolsys.record.io.format.openstreetmap.model.OsmDocument)

Example 4 with OsmDocument

use of com.revolsys.record.io.format.openstreetmap.model.OsmDocument in project com.revolsys.open by revolsys.

the class OpenStreetMapApiLayer method getRecords.

@Override
public List<LayerRecord> getRecords(BoundingBox boundingBox) {
    if (hasGeometryField()) {
        boundingBox = convertBoundingBox(boundingBox);
        if (Property.hasValue(boundingBox)) {
            final Map<Identifier, LayerRecord> recordMap = new HashMap<>();
            final List<BoundingBox> boundingBoxes = getTileBoundingBoxes(boundingBox);
            for (final BoundingBox tileBoundingBox : boundingBoxes) {
                final OsmDocument document = getTile(tileBoundingBox);
                for (final OsmElement record : document.getRecords()) {
                    final Geometry geometry = record.getGeometry();
                    if (geometry != null && !geometry.isEmpty()) {
                        if (boundingBox.intersects(geometry.getBoundingBox())) {
                            final Identifier identifier = record.getIdentifier();
                            final OsmProxyLayerRecord layerRecord = new OsmProxyLayerRecord(this, document, identifier);
                            recordMap.put(identifier, layerRecord);
                        }
                    }
                }
            }
            this.boundingBoxTileMap.keySet().retainAll(boundingBoxes);
            return new ArrayList<>(recordMap.values());
        }
    }
    return Collections.emptyList();
}
Also used : OsmElement(com.revolsys.record.io.format.openstreetmap.model.OsmElement) Geometry(com.revolsys.geometry.model.Geometry) Identifier(com.revolsys.identifier.Identifier) HashMap(java.util.HashMap) BoundingBox(com.revolsys.geometry.model.BoundingBox) ArrayList(java.util.ArrayList) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) OsmDocument(com.revolsys.record.io.format.openstreetmap.model.OsmDocument)

Aggregations

OsmDocument (com.revolsys.record.io.format.openstreetmap.model.OsmDocument)4 BoundingBox (com.revolsys.geometry.model.BoundingBox)2 Geometry (com.revolsys.geometry.model.Geometry)2 Identifier (com.revolsys.identifier.Identifier)2 OsmElement (com.revolsys.record.io.format.openstreetmap.model.OsmElement)2 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2