Skip to content

Commit

Permalink
Merge pull request #21 from matafokka/development
Browse files Browse the repository at this point in the history
v1.0.1. Bug fixes, small visuals update
  • Loading branch information
matafokka authored Jun 8, 2022
2 parents 8dd65f5 + ba3a339 commit 5d27d0a
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 63 deletions.
22 changes: 13 additions & 9 deletions SynthBaseLayer/Hull.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ L.ALS.SynthBaseLayer.prototype.connectHullToAirport = function () {

let [p1, p2] = toRemove.getLatLngs();
hullConnection.setLatLngs([p1, airportPos, p2]);
path.updateWidgets(minLen + path.hullLength);
path.pathLength = minLen + path.hullLength;
path.updateWidgets(path.pathLength);
}
}

Expand Down Expand Up @@ -301,12 +302,15 @@ L.ALS.SynthBaseLayer.prototype.hullToCycles = function (path) {
return undefined;

if (path.hullConnections.length === 0) {
let airportPos = this.airportMarker.getLatLng();
return [[
airportPos,
...path.pathGroup.getLayers()[0].getLatLngs(),
airportPos
]];
let layer = path.pathGroup.getLayers()[0],
airportPos = this.airportMarker.getLatLng(),
cycle = [
airportPos,
...layer.getLatLngs(),
airportPos
];
cycle.pathLength = path.pathLength;
return [cycle];
}

// The idea is to start with the first connection, find the starting point in it and for each connection
Expand Down Expand Up @@ -372,7 +376,7 @@ L.ALS.SynthBaseLayer.prototype.hullToCycles = function (path) {
}

let toReturn = [hullP2, ...afterAirport, ...beforeAirport, hullP2];
toReturn.pathLength = path.hullLength;
toReturn.pathLength = path.pathLength;
return [toReturn];
}

Expand All @@ -399,5 +403,5 @@ L.ALS.SynthBaseLayer.prototype.getOrderedPathFromHull = function (prevPoint, con
L.ALS.SynthBaseLayer.prototype.cross = function (a, b, o) {
// It calculates only direction, so it should be good enough. Also, we wrap lngs to get correct direction on
// lng differences > 90 and near map's edges
return (MathTools.wrapLng(o.lng, a.lng) - o.lng) * (b.lat - o.lat) - (a.lat - o.lat) * (MathTools.wrapLng(o.lng, b.lng) - o.lng);
return this.toFixed((MathTools.wrapLng(o.lng, a.lng) - o.lng) * (b.lat - o.lat) - (a.lat - o.lat) * (MathTools.wrapLng(o.lng, b.lng) - o.lng));
}
5 changes: 3 additions & 2 deletions SynthGeometryBaseWizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ L.ALS.SynthGeometryBaseWizard = L.ALS.Wizard.extend(/** @lends L.ALS.SynthGeomet

}).catch((reason) => {
// If reason is string, proj4js doesn't support file projection
console.log(reason);
if (typeof reason === "string") {
callback("ProjectionNotSupported");
return;
Expand Down Expand Up @@ -139,7 +140,7 @@ L.ALS.SynthGeometryBaseWizard = L.ALS.Wizard.extend(/** @lends L.ALS.SynthGeomet
}

let layersAdded = false;
L.geoJson(geoJson, {
let leafletGeoJson = L.geoJson(geoJson, {
onEachFeature: (feature, layer) => {
if (!(layer instanceof layerType))
return;
Expand All @@ -150,7 +151,7 @@ L.ALS.SynthGeometryBaseWizard = L.ALS.Wizard.extend(/** @lends L.ALS.SynthGeomet
});

if(layersAdded)
this.checkGeoJSONBounds(geoJson);
this.checkGeoJSONBounds(leafletGeoJson);
else
window.alert(L.ALS.locale.initialFeaturesNoFeatures);

Expand Down
4 changes: 2 additions & 2 deletions SynthGridLayer/SynthGridLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ L.ALS.SynthGridLayer = L.ALS.SynthRectangleBaseLayer.extend(/** @lends L.ALS.Syn

this.polygons = {};

L.ALS.SynthRectangleBaseLayer.prototype.init.call(this, wizardResults, settings);

/**
* Whether or not cells above 60 lat should be merged
* @type {boolean}
*/
this.shouldMergeCells = wizardResults.gridShouldMergeCells;

L.ALS.SynthRectangleBaseLayer.prototype.init.call(this, wizardResults, settings);

this.addEventListenerTo(this.map, "zoomend", "_onMapZoom");
this.addEventListenerTo(this.map, "moveend resize", "_onMapPan");
},
Expand Down
18 changes: 8 additions & 10 deletions SynthGridLayer/onMapPan.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ L.ALS.SynthGridLayer.prototype._onMapPan = function () {
this.clearLabels("gridLabelsIDs");

// Get viewport bounds and calculate correct start and end coords for lng and lat
let bounds = this.map.getBounds(), north = bounds.getNorth(), west = bounds.getWest(),
lngFrom = this._closestLess(west, this.lngDistance),
lngTo = this._closestGreater(bounds.getEast(), this.lngDistance),
let bounds = this.map.getBounds(), north = bounds.getNorth(), west = bounds.getWest(), east = bounds.getEast(),
latFrom = this._closestLess(bounds.getSouth(), this.latDistance),
latTo = this._closestGreater(north, this.latDistance);

Expand All @@ -37,20 +35,22 @@ L.ALS.SynthGridLayer.prototype._onMapPan = function () {
// We will use toFixed() to generate lat and lng labels and to fix floating point errors in generating polygons' names

for (let lat = latFrom; lat <= latTo; lat += this.latDistance) { // From bottom (South) to top (North)
let absLat = this.toFixed(lat > 0 ? lat - this.latDistance : lat);
createLabel([lat, west], absLat, "leftCenter", true);
createLabel([lat, west], this.toFixed(lat), "leftCenter", true);

// Merge sheets when lat exceeds certain value. Implemented as specified by this document:
// https://docs.cntd.ru/document/456074853
let mergedSheetsCount = 1;
if (this.shouldMergeCells) {
absLat = Math.abs(lat);
let absLat = Math.abs(this.toFixed(lat > 0 ? lat + this.latDistance : lat));
if (absLat > 76)
mergedSheetsCount = (this._currentStandardScale === 200000 || this._currentStandardScale === 2000) ? 3 : 4;
else if (absLat > 60)
mergedSheetsCount = 2;
}
let lngDistance = this.lngDistance * mergedSheetsCount;

let lngDistance = this.lngDistance * mergedSheetsCount,
lngFrom = this._closestLess(west, lngDistance),
lngTo = this._closestGreater(east, lngDistance);

for (let lng = lngFrom; lng <= lngTo; lng += lngDistance) { // From left (West) to right (East)
if (lng < -180 || lng > 180 - lngDistance)
Expand All @@ -62,10 +62,8 @@ L.ALS.SynthGridLayer.prototype._onMapPan = function () {
let polygon = this.initPolygon(lat, lng, lngDistance);

// Generate current polygon's name if grid uses one of standard scales
if (this._currentStandardScale === Infinity) {
polygon.polygonName = "Not in standard scale system";
if (this._currentStandardScale === Infinity)
continue;
}

// Firstly, we round our coordinates to avoid floating-point errors.
// Secondly, our point lies on bottom left corner. To avoid dealing with points on lines and errors related to it, we need to add some value to each coordinate.
Expand Down
12 changes: 10 additions & 2 deletions SynthLineLayer/SynthLineLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ L.ALS.SynthLineLayer = L.ALS.SynthBaseLayer.extend(/** @lends L.ALS.SynthLineLay
},

onEditEnd: function (event, notifyIfLayersSkipped = true) {
if (!this.isSelected)
if (!this.isSelected && !this.isAfterDeserialization)
return;

this.pathsGroup.clearLayers();
Expand Down Expand Up @@ -137,9 +137,17 @@ L.ALS.SynthLineLayer = L.ALS.SynthBaseLayer.extend(/** @lends L.ALS.SynthLineLay
pathsMeta[prop] = this[prop];
}

let points = this.pointsGroup.toGeoJSON();
for (let feature of points.features)
feature.properties.name = "Capture point";

let airport = this.airportMarker.toGeoJSON();
airport.properties.name = "Airport";

return geojsonMerge.merge([
L.ALS.SynthBaseLayer.prototype.toGeoJSON.call(this, pathsMeta),
this.pointsGroup.toGeoJSON(),
points,
airport
]);
},

Expand Down
6 changes: 3 additions & 3 deletions SynthPolygonBaseLayer/SynthPolygonBaseLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,18 @@ L.ALS.SynthPolygonBaseLayer = L.ALS.SynthBaseLayer.extend( /** @lends L.ALS.Synt

this.forEachValidPolygon(polygon => {
let polygonJson = polygon.toGeoJSON(),
props = ["polygonName", "minHeight", "maxHeight", "meanHeight", "absoluteHeight", "reliefType", "elevationDifference", "latCellSizeInMeters", "lngCellSizeInMeters"];
props = ["minHeight", "maxHeight", "meanHeight", "absoluteHeight", "reliefType", "elevationDifference", "latCellSizeInMeters", "lngCellSizeInMeters"];
for (let prop of props) {
let value = polygon[prop];
if (value !== undefined)
polygonJson.properties[prop] = value;
}
polygonJson.properties.name = "Selected cell";
polygonJson.properties.name = polygon.polygonName || "Area to capture";
jsons.push(polygonJson);
});

let airport = this.airportMarker.toGeoJSON();
airport.name = "Airport";
airport.properties.name = "Airport";
jsons.push(airport);

return jsons;
Expand Down
13 changes: 9 additions & 4 deletions SynthPolygonLayer/SynthPolygonLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ L.ALS.SynthPolygonLayer = L.ALS.SynthPolygonBaseLayer.extend(/** @lends L.ALS.Sy
},

onEditEnd: function (e, notifyIfLayersSkipped = true) {
if (!this.isSelected)
if (!this.isSelected && !this.isAfterDeserialization)
return;

this.labelsGroup.deleteAllLabels();
Expand Down Expand Up @@ -184,6 +184,11 @@ L.ALS.SynthPolygonLayer = L.ALS.SynthPolygonBaseLayer.extend(/** @lends L.ALS.Sy
p2y += dy;

line = [[p1x, p1y], [p2x, p2y]];

// Fix wrong swapping
if (!shouldSwapPoints)
line.reverse();

lineAfterPolygonAdded = true;
}
}
Expand Down Expand Up @@ -372,9 +377,9 @@ L.ALS.SynthPolygonLayer = L.ALS.SynthPolygonBaseLayer.extend(/** @lends L.ALS.Sy
let jsons = this.baseFeaturesToGeoJSON();

this.pointsGroup.eachLayer(layer => {
let pointsJson = layer.toGeoJSON();
pointsJson.name = "capturePoint";
jsons.push(pointsJson);
let pointJson = layer.toGeoJSON();
pointJson.properties.name = "Capture point";
jsons.push(pointJson);
});

let props = {}
Expand Down
6 changes: 3 additions & 3 deletions SynthRectangleBaseLayer/toGeoJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ L.ALS.SynthRectangleBaseLayer.prototype.toGeoJSON = function () {

jsons.push(L.ALS.SynthBaseLayer.prototype.toGeoJSON.call(this, parallelsProps, meridiansProps));

let pointsParams = [["capturePointsByMeridians", this.latPointsGroup], ["capturePointsByParallels", this.lngPointsGroup]];
let pointsParams = [["Capture point by meridians", this.latPointsGroup], ["Capture point by parallels", this.lngPointsGroup]];
for (let param of pointsParams) {
param[1].eachLayer((layer) => {
param[1].eachLayer(layer => {
let pointsJson = layer.toGeoJSON();
pointsJson.name = param[0];
pointsJson.properties.name = param[0];
jsons.push(pointsJson);
});
}
Expand Down
2 changes: 1 addition & 1 deletion SynthRectangleLayer/SynthRectangleLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ L.ALS.SynthRectangleLayer = L.ALS.SynthRectangleBaseLayer.extend(/** @lends L.AL
},

onEditEnd: function (e, notifyIfLayersSkipped = true) {
if (!this.isSelected)
if (!this.isSelected && !this.isAfterDeserialization)
return;

this.clearPaths();
Expand Down
16 changes: 8 additions & 8 deletions locales/Russian.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ L.ALS.Locales.addLocaleProperties("Русский", {
gridWizardDisplayName: "Слой Сетки",
gridWizardNotification: `Если масштаб карты слишком мелкий, сетка будет скрыта. Пожалуйста, увеличьте масштаб карты, чтобы ее увидеть.
Чтобы выделить трапецию, или нажмите на него правой кнопкой мыши (или задержите палец на сенсорном экране), или два раза кликните (тапните) на него.`,
Чтобы выделить трапецию, нажмите на нее правой кнопкой мыши (или задержите палец на сенсорном экране) или два раза кликните (тапните) по ней.`,

gridStandardScales: "Масштаб сетки:",
gridLngDistance: "Расстояние между параллелями:",
Expand Down Expand Up @@ -62,20 +62,20 @@ L.ALS.Locales.addLocaleProperties("Русский", {
airportLat: "Широта аэропорта:",
airportLng: "Долгота аэропорта:",
aircraftSpeed: "Скорость самолета (km/h):",
imageScale: "Делитель масштаба изображения:",
imageScale: "Делитель масштаба снимка:",
cameraWidth: "Ширина камеры (px):",
cameraHeight: "Высота камеры (px):",
pixelWidth: "Размер пикселя (μm):",
overlayBetweenPaths: "Перекрытие между изображениями с соседних маршрутов (%):",
overlayBetweenImages: "Перекрытие между изображениями с одного маршрута (%):",
overlayBetweenPaths: "Перекрытие между снимками с соседних маршрутов (%):",
overlayBetweenImages: "Перекрытие между снимками с одного маршрута (%):",
focalLength: "Фокусное расстояние (mm):",
selectedArea: "Площадь выделенных трапеций",
flightHeight: "Высота полета",
lx: "Высота изображения, lx",
Lx: "Высота изображения на местности, Lx",
lx: "Высота снимка, lx",
Lx: "Высота снимка на местности, Lx",
Bx: "Расстояние между точками фотографирования, Bx",
ly: "Ширина изображения, ly",
Ly: "Ширина изображения на местности, Ly",
ly: "Ширина снимка, ly",
Ly: "Ширина снимка на местности, Ly",
By: "Расстояние между соседними маршрутами, By",
timeBetweenCaptures: "Временной промежуток между снимками",

Expand Down
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "synthflight",
"productName": "SynthFlight",
"version": "1.0.0",
"version": "1.0.1",
"description": "A fully client-side software for planning aerial photography",
"main": "electronApp.js",
"browser": "index.html",
Expand Down Expand Up @@ -77,7 +77,7 @@
"electron-packager": "^15.4.0",
"fs-extra": "^9.0.1",
"geotiff": "^1.0.4",
"geotiff-geokeys-to-proj4": "^2021.10.31",
"geotiff-geokeys-to-proj4": "^2022.5.28",
"http-server": "^0.12.3",
"keyboardevent-key-polyfill": "^1.1.0",
"leaflet": "^1.7.1",
Expand All @@ -101,6 +101,6 @@
},
"dependencies": {
"@electron/remote": "^2.0.1",
"leaflet-advanced-layer-system": "^2.2.6"
"leaflet-advanced-layer-system": "^2.2.8"
}
}

0 comments on commit 5d27d0a

Please sign in to comment.