Skip to content

Commit bbbbc90

Browse files
committed
make hotspot.js
1 parent 83fff9e commit bbbbc90

File tree

10 files changed

+393
-495
lines changed

10 files changed

+393
-495
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,29 @@ var property2 = { ...}
142142
showProperty([property1, property2,..], 'graph');
143143
```
144144

145+
#### View hotspot cube
146+
147+
* show3DHotSpotMovingPoint([mf_arr], x_deg, y_deg, time_deg, max_height)
148+
149+
Show Hotspot cube for MovingPoint Array.
150+
151+
'x_deg' is how much divide longitude.
152+
153+
'y_deg' is latitude.
154+
155+
'time_deg' is seconds.
156+
157+
'max_height' is meters that assume how much maximum height. it can be omitted.(default 15000000)
158+
159+
```js
160+
scene.primitives.add(show3DHotSpotMovingPoint(mf_arr, 1, 1, 3600));
161+
```
162+
163+
e.g.
164+
165+
![hotspotPoint](http://i.imgur.com/7pN8bDz.png)
166+
167+
145168
- - -
146169

147170
## Building

js/MFOC/Model.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function BoxCoord(){
2+
this.minimum = {};
3+
this.maximum = {};
4+
};

js/MFOC/README.md

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
# Moving Feature On Cesium
1+
# Moving Feature On Cesium (MFOC)
22

3-
## Visualize Movement
3+
We are developing API for this project.
4+
5+
[OGC Moving Features Encoding Extension - JSON](https://ksookim.github.io/mf-json/)
6+
7+
8+
#### Visualize Movement
49

510
* movePolygonArray([movingfeature_array], with_height);
611

712
movingfeature is moving feature json object array.
813

14+
It should be have 'temporalGeometry' key.
15+
916
'with_height' means path of animation with own height.(boolean)
1017

11-
return czml.
18+
Returns [czml](https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/CZML-Guide) object.
1219

1320
```js
1421
var mf1 = {
@@ -32,25 +39,30 @@ var mf1 = {
3239
"name" : "Max wind speed",
3340
"uom" : "kt",
3441
"values" : [ 0.0, 0.0,..., 0.0, 0.0 ],
35-
"datetimes" : [ "2015-07-30 03:00:00",.., "2015-08-11 03:00:00", "2015-08-11 09:00:00", "2015-08-11 15:00:00", "2015-08-11 21:00:00", "2015-08-12 03:00:00", "2015-08-12 09:00:00" ],
42+
"datetimes" : [ "2015-07-30 03:00:00",.., "2015-08-12 09:00:00" ],
3643
"interpolations" : "Linear"
3744
} ]
3845
}
3946
var mf_arr = [ mf1, mf2 ]; //mf is movingfeature object.
4047
var czml = movePolygonArray(mf_arr);
4148
```
4249

43-
* movePointArray([mf_arr], with_height);
50+
* movePointArray([mf_arr], with_height)
4451

45-
* moveLineStringArray([mf_arr], with_height);
52+
Returns czml object.
4653

47-
## Draw Primitive
54+
* moveLineStringArray([mf_arr], with_height)
55+
56+
Returns czml object.
57+
58+
59+
#### Draw Primitive
4860

4961
* drawPolygons([mf_arr], with_height)
5062

51-
draw multiple Polygon.
63+
Draw multiple Polygon.
5264

53-
return Cesium.primitiveCollection
65+
Return Cesium.primitiveCollection.
5466

5567
* drawTyphoons([mf_arr], with_height)
5668

@@ -64,14 +76,43 @@ draw multiple Point.
6476

6577
draw multiple LineString.
6678

67-
## view Properties graph
79+
* drawPointsPath([mf_arr], with_height)
80+
81+
Returns Cesium.PolylineCollection. Draw path for MovingPoint.
82+
83+
* drawLinesPath([mf_arr], with_height)
84+
85+
Returns Cesium.PrimitiveCollection. Draw triangles using each linestring points.
86+
87+
88+
#### Draw IndoorGML Data (With Z-value)
89+
90+
* drawPointsWithZvalue([mf_arr], with_height);
91+
92+
Returns Cesium.PointPrimitiveCollection. z-value apperas in color.
93+
94+
```js
95+
$.getJSON('json_data/indoor.json').then(
96+
function(data){
97+
var mf_arr = [];
98+
for (var i = 0 ; i < data.features.length ; i++){
99+
mf_arr.push(data.features[i]);
100+
}
101+
scene.primitives.add(drawPointsWithZvalue(mf_arr, true));
102+
}
103+
);
104+
```
105+
106+
#### View Properties graph
68107

69108
* showProperty([obj_arr], div_id)
70109

71-
showProperties by d3 graph. (https://github.com/d3/d3/blob/master/API.md)
110+
Show Property graph by [d3](https://github.com/d3/d3/blob/master/API.md).
111+
112+
It is recommended that propery objects have same attributes.
72113

73114
```js
74-
<div id="graph" class="graph" > </svg>
115+
<div id="graph" class="graph" > </div>
75116
var property1 = {
76117
"name" : "central pressure",
77118
"uom" : "hPa",
@@ -82,3 +123,25 @@ var property1 = {
82123
var property2 = { ...}
83124
showProperty([property1, property2,..], 'graph');
84125
```
126+
127+
#### View hotspot cube
128+
129+
* show3DHotSpotMovingPoint([mf_arr], x_deg, y_deg, time_deg, max_height)
130+
131+
Show Hotspot cube for MovingPoint Array.
132+
133+
'x_deg' is how much divide longitude.
134+
135+
'y_deg' is latitude.
136+
137+
'time_deg' is seconds.
138+
139+
'max_height' is meters that assume how much maximum height. it can be omitted.(default 15000000)
140+
141+
```js
142+
scene.primitives.add(show3DHotSpotMovingPoint(mf_arr, 1, 1, 3600));
143+
```
144+
145+
e.g.
146+
147+
![hotspotPoint](http://i.imgur.com/7pN8bDz.png)

js/MFOC/draw.js

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -440,34 +440,61 @@ function drawTrinaglesWithNextPos(line_1, line_2, height1, height2, with_height)
440440
}
441441

442442

443-
function drawOneCube(lower, upper, ){
444-
445-
/*
443+
function drawOneCube(positions, rating = 1.0){
444+
var red_rate = 1.0, green_rate = (-2 * rating) + 2;
445+
446+
var rating_color = new Cesium.Color(
447+
1.0,
448+
green_rate,
449+
0.0,
450+
rating
451+
);
452+
453+
if (rating < 0){
454+
rating_color = new Cesium.Color(
455+
1.0,
456+
green_rate,
457+
0.5,
458+
0.2
459+
);
460+
}
461+
var size = calcSidesBoxCoord(positions);
446462

447-
var prim = new Cesium.Primitive({
448-
geometryInstances : instances,
449-
appearance : new Cesium.PerInstanceColorAppearance({
450-
translucent : true
451-
}),
452-
show : true
453-
});
463+
var geometry = Cesium.BoxGeometry.fromDimensions({
464+
vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
465+
dimensions : new Cesium.Cartesian3( size[0], size[1], size[2] )
466+
});
467+
//console.log(positions, geometry);
468+
var position = Cesium.Cartesian3.fromDegrees( (positions.minimum.x + positions.maximum.x) / 2, (positions.maximum.y + positions.minimum.y) /2 , (positions.minimum.z + positions.maximum.z) / 2);
454469

470+
var point3d = new Cesium.Cartesian3( 0.0, 0.0, 0.0 );
471+
var translation = Cesium.Transforms.eastNorthUpToFixedFrame( position );
472+
var matrix = Cesium.Matrix4.multiplyByTranslation( translation, point3d, new Cesium.Matrix4() );
455473

456-
var p_geometry = Cesium.PolygonGeometry.createGeometry(polygon);
457474

458-
return (new Cesium.GeometryInstance({
459-
geometry : p_geometry,
460-
attributes : {
461-
color : Cesium.ColorGeometryInstanceAttribute.fromColor(r_color)
462-
}
475+
var geo_instance = new Cesium.GeometryInstance({
476+
geometry : geometry,
477+
modelMatrix : matrix,
478+
attributes : {
479+
color : Cesium.ColorGeometryInstanceAttribute.fromColor(rating_color)
480+
}
463481

464-
} ));
482+
} );
465483

466-
var box = new Cesium.BoxGeometry({
467-
vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
468-
maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0),
469-
minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0)
484+
return new Cesium.Primitive({
485+
geometryInstances : geo_instance,
486+
appearance : new Cesium.PerInstanceColorAppearance({
487+
translucent : true
488+
}),
489+
show : true
470490
});
471-
*/
472491

473492
}
493+
494+
function calcSidesBoxCoord(box_coord){
495+
var x_dist = Cesium.Cartesian3.distance(Cesium.Cartesian3.fromDegrees(box_coord.minimum.x, box_coord.minimum.y, box_coord.minimum.z), Cesium.Cartesian3.fromDegrees(box_coord.maximum.x, box_coord.minimum.y, box_coord.minimum.z));
496+
var y_dist = Cesium.Cartesian3.distance(Cesium.Cartesian3.fromDegrees(box_coord.minimum.x, box_coord.minimum.y, box_coord.minimum.z), Cesium.Cartesian3.fromDegrees(box_coord.minimum.x, box_coord.maximum.y, box_coord.minimum.z));
497+
var z_dist = Cesium.Cartesian3.distance(Cesium.Cartesian3.fromDegrees(box_coord.minimum.x, box_coord.minimum.y, box_coord.minimum.z), Cesium.Cartesian3.fromDegrees(box_coord.minimum.x, box_coord.minimum.y, box_coord.maximum.z));
498+
499+
return [x_dist, y_dist, z_dist];
500+
}

js/MFOC/draw_indoor.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ var drawPointsWithZvalue = function(mf_arr, with_height){
99
var pointCollection = new Cesium.PointPrimitiveCollection();
1010
var min_max = findAllMinMaxTimeAndZ(mf_arr, true);
1111

12-
LOG(min_max.value);
1312
for (var id = 0 ; id < mf_arr.length ; id++){
1413
var r_color = Cesium.Color.fromRandom({
1514
red : 0.0,

0 commit comments

Comments
 (0)