Skip to content

Commit 8700d1f

Browse files
committed
Make OpenBuildings instantiator work
1 parent d9b12da commit 8700d1f

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

klab.engine/src/main/java/org/integratedmodelling/klab/components/processing/openbuildings/OpenBuildingsInstantiator.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public Object eval(IContextualizationScope scope, Object... parameters) {
7575
@Override
7676
public List<IObjectArtifact> instantiate(IObservable semantics, IContextualizationScope scope) throws KlabException {
7777
List<IObjectArtifact> ret = new ArrayList<>();
78-
String tilesfile = "klab.engine/src/main/resources/components/org.integratedmodelling.geospace/openbuildings/tiles.geojson";
78+
String tilesfile = "../../klab.engine/src/main/resources/components/org.integratedmodelling.geospace/openbuildings/tiles.geojson";
7979

8080
Geometry contextGeometry = ((Shape) contextSubject.getScale().getSpace().getShape()).getJTSGeometry();
8181

@@ -105,8 +105,8 @@ public List<IObjectArtifact> instantiate(IObservable semantics, IContextualizati
105105
// Get properties (attributes)
106106
System.out.println("Properties:");
107107
for (Property property : feature.getProperties()) {
108-
if (property.getName().equals("tile_url")) {
109-
downloadableFiles.add(tilesfile);
108+
if (property.getName().toString().equals("tile_url")) {
109+
downloadableFiles.add(property.getValue().toString());
110110
}
111111
}
112112
}
@@ -133,15 +133,16 @@ public List<IObjectArtifact> instantiate(IObservable semantics, IContextualizati
133133
double lat = Double.parseDouble(record.get(0));
134134
double lon = Double.parseDouble(record.get(1));
135135

136-
if (!contextGeometry.contains(Shape.makePoint(lat, lon))) { // TODO check coordinates
136+
if (!contextGeometry.contains(Shape.makePoint(lon, lat))) { // TODO check coordinates
137137
continue;
138138
}
139139
IMetadata metadata = new Metadata();
140140
metadata.put("confidence", Double.parseDouble(record.get(3)));
141141
metadata.put("area_in_meters", Double.parseDouble(record.get(2)));
142142
String geometryWkt = record.get(4);
143143

144-
Shape buildingShape = Shape.create(geometryWkt, Projection.create("EPSG:3857"));
144+
Shape buildingShape = Shape.create(geometryWkt, Projection.create(Projection.DEFAULT_PROJECTION_CODE));
145+
//buildingShape = buildingShape.transform(Projection.create(Projection.DEFAULT_PROJECTION_CODE));
145146
String id = CamelCase.toLowerCase(Observables.INSTANCE.getDisplayName(semantics), '-') + "_" + n++;
146147
ISubject subject = (ISubject) scope.newObservation(semantics, id, getScale(buildingShape, contextSubject), metadata);
147148

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@klab 0.10.0
2+
@version 0.10.0
3+
@namespace gis.openbuildings
4+
5+
const export object query
6+
""
7+
label 'Query OpenBuildings'
8+
{
9+
10+
optional number threshold
11+
""
12+
default 90
13+
14+
class org.integratedmodelling.klab.components.processing.openbuildings.OpenBuildingsInstantiator
15+
}

0 commit comments

Comments
 (0)