forked from vvoovv/djeo-povray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
osm2pov.js
109 lines (105 loc) · 2.42 KB
/
osm2pov.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
require(
{
baseUrl: "../dojo",
djeoEngine: "povray",
paths: {djeo: "../djeo"}
},
[
"dojo/has",
"djeo/Map",
"djeo/parser/osm",
"dojo/_base/json"
], function(has, Map, osm, json){
var inputArgs = {
inputFile: 0,
outputFile: 0,
lookAt: 0
};
var style = [
{
filter: "this.type=='Polygon' && this.building",
height: 15,
roofAngle: 40,
roofTexture: "Roof_Texture",
wallTexture: "Wall_Texture_Outside",
handler: "makeBuilding"
},
{
filter: "this.landuse=='forest' || this.natural=='wood' || this.leisure=='park'",
trees: ["object{Tree_00 scale 2}", "object{Tree_10 scale 2}"],
ratios: [40, 60],
treeCellX: 3,
treeCellZ: 3,
scaleFactor: 0.4,
maxTiltAngle: 10,
treeTexture: "Tree_10_Texture",
handler: "makeForest"
},
{
filter: "this.type=='LineString' && (this.highway=='primary' || this.highway=='secondary' || this.highway=='tertiary' || this.highway=='residential')",
stripes: [[-4.4, 0.3], [4.4, 0.3], [0, 0.3]],
width: 10,
highwayTexture: "Asphalt",
highwayHeight: 0.01,
stripesTexture: "Stripes",
stripesHeight: 0.01,
handler: "makeRoad"
},
{
filter: "this.type=='LineString' && this.highway=='footway'",
width: 2,
highwayTexture: "Footway",
highwayHeight: 0.001,
handler: "makeRoad"
}
];
require(
has("host-browser") ? [
"djeo/control/Navigation",
"djeo/control/Highlight",
"djeo/control/Tooltip",
"dojo/domReady!"
] : [], function(Navigation, Highlight, Tooltip){
// process command line arguments
var numArgs = process.argv.length
if (numArgs<5) {
console.error("Please specify output file and camera parameters");
return;
}
for (var i=3; i<numArgs; i++) {
var split = process.argv[i].split(/=/),
key = split[0],
value = split[1]
;
if (key in inputArgs) {
if (value.indexOf(",")>=0) {
// we have an object; parse it
value = json.fromJson("{"+value+"}");
}
inputArgs[key] = value;
}
else {
console.log("Unknown key: "+key);
}
}
if (!(inputArgs.inputFile && inputArgs.lookAt)) return
var output = has("host-browser") ? "toConsole" : "toFile";
var map = new Map("map", {
style: style,
userProjection: "EPSG:4326",
lookAt: inputArgs.lookAt,
engineOptions: {povray: {
output: output,
outputFile: inputArgs.outputFile || "osm.pov"
}},
features: osm.parseFromUrl(inputArgs.inputFile)
});
map.ready(function(){
if (has("host-browser")) {
new Navigation(map);
new Highlight(map);
new Tooltip(map);
}
});
});
});