-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuildings.groovy
69 lines (49 loc) · 1.36 KB
/
buildings.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import com.esri.core.geometry.Geometry
import com.esri.core.geometry.MultiPath
import com.esri.core.geometry.Polygon
import com.osmimport.model.OSMEntity
import com.osmimport.model.OSMEntityGeometry
// construction de la chaine
builder.build(osmstream) {
// défini un flux de sortie, et description de la structure
sortie = gdb(path : var_gdb) {
featureclass("buildings", ESRI_GEOMETRY_POLYGON,"WGS84") {
_integer('id')
_text("type")
}
}
// a stream
b = stream(osmstream, label:"buildings") {
filter {
e ->
isPolygon(e) && has(e,"building")
}
transform { e ->
on(e).newValue("id",e.id).map("building").into("type").end()
return e;
}
}
l = stream(osmstream, label:"building lines") {
filter {
e -> isPolyline(e) && has(e,"building")
}
transform {
e ->
Geometry g = e.getGeometry()
if (g == null || g.isEmpty())
{
return null;
}
Polygon p = new Polygon()
p.add((MultiPath)g,false)
Map<String,String> newFields = new HashMap<String,String>()
newFields.put("type",e.getFields().get("building") )
newFields.put("id", e.getId())
f = new OSMEntityGeometry(e.getId(), p ,newFields);
return f;
}
}
// flux de sortie
out(streams : [b,l], sink : sortie, tablename:"buildings")
// out(streams : l, sink : sortie, tablename:"buildings_line")
}