EOX GitLab Instance

Commit de9710ef authored by Mussab Abdalla's avatar Mussab Abdalla
Browse files

rectangle lines as lon/lat instead of great circle

parent 4c01a4a1
......@@ -628,11 +628,39 @@ class CesiumMapView extends Marionette.ItemView {
};
if (polygon) {
coordinates = polygon.polygon.hierarchy.getValue().positions;
coordinates = coordinates.map((position) => [
Cesium_Math.toDegrees(Cartographic.fromCartesian(position).longitude),
Cesium_Math.toDegrees(Cartographic.fromCartesian(position).latitude),
]);
if (model.get("tool") === "polygon") {
coordinates = polygon.polygon.hierarchy.getValue().positions;
coordinates = coordinates.map((position) => [
Cesium_Math.toDegrees(Cartographic.fromCartesian(position).longitude),
Cesium_Math.toDegrees(Cartographic.fromCartesian(position).latitude),
]);
} else {
var positions = polygon.rectangle.coordinates.getValue();
var first = new Cartographic(positions.south, positions.west);
var second = new Cartographic(positions.north, positions.west);
var third = new Cartographic(positions.north, positions.east);
var fourth = new Cartographic(positions.south, positions.east);
coordinates = [
[
Cesium_Math.toDegrees(first.longitude),
Cesium_Math.toDegrees(first.latitude),
],
[
Cesium_Math.toDegrees(second.longitude),
Cesium_Math.toDegrees(second.latitude),
],
[
Cesium_Math.toDegrees(third.longitude),
Cesium_Math.toDegrees(third.latitude),
],
[
Cesium_Math.toDegrees(fourth.longitude),
Cesium_Math.toDegrees(fourth.latitude),
],
];
}
geoJsonArea.geometry.type = "Polygon";
coordinates.push(coordinates[0]);
geoJsonArea.geometry.coordinates = [coordinates];
......@@ -661,7 +689,8 @@ class CesiumMapView extends Marionette.ItemView {
model.set("area", geoJsonArea);
}
drawShape(map, positionData, validate) {
drawShape(map, positionData, validate, model) {
var shape;
var drawn = map.entities.getById("draw");
var identifier = null;
// remove the previous polygon and draw the last polygon
......@@ -669,13 +698,23 @@ class CesiumMapView extends Marionette.ItemView {
map.entities.remove(drawn);
identifier = "draw";
}
var shape = map.entities.add({
id: identifier,
polygon: {
hierarchy: positionData,
material: new ColorMaterialProperty(Color.GRAY.withAlpha(0.3)),
},
});
if (model && model.get("tool") === "bbox") {
shape = map.entities.add({
id: identifier,
rectangle: {
coordinates: new Rectangle.fromCartesianArray(positionData),
material: new ColorMaterialProperty(Color.GRAY.withAlpha(0.3)),
},
});
} else {
shape = map.entities.add({
id: identifier,
polygon: {
hierarchy: positionData,
material: new ColorMaterialProperty(Color.GRAY.withAlpha(0.3)),
},
});
}
return shape;
}
......@@ -830,10 +869,10 @@ class CesiumMapView extends Marionette.ItemView {
//click function
handler.setInputAction((movement) => {
function terminateShape(map) {
function terminateShape(map, model) {
// draw shape only if there are more than (2 double click + 1) points created
drawShape(map, activeShapePoints, true);
drawShape(map, activeShapePoints, true, model);
floatingPoint = undefined;
activeShape = undefined;
......@@ -978,7 +1017,7 @@ class CesiumMapView extends Marionette.ItemView {
}, false);
activeShape = drawShape(map, dynamicPositions);
} else {
terminateShape(map);
terminateShape(map, model);
onDrawFinished(map, model);
clearPoints(map);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment