Skip to content

Commit

Permalink
fix: correct geometry persistence + area calcs
Browse files Browse the repository at this point in the history
- remove call to calculate geodesic area for L.Marker dots
- fix key ref used to retrieve persisted geometry from local storage

resolves #52
  • Loading branch information
alee committed Oct 7, 2020
1 parent ba1f3fd commit 8b96a50
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions app/pages/dataset/_id/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,13 @@ class DatasetDetail extends Vue {
loadGeoJson(event) {
const file = event.target.files[0]
file.text().then((text) => {
console.log('received possible geojson to load')
console.log(text)
console.log('received possible geojson to load: ', text)
try {
let area = JSON.parse(text)
this.restoreSelectedGeometry(area)
} catch (error) {
console.error(error)
// FIXME: this should be a toast or other notification
alert("Sorry! We couldn't re-import this file: " + text)
}
})
Expand Down Expand Up @@ -537,16 +537,15 @@ class DatasetDetail extends Vue {
layer.getRadius(),
this.defaultCircleToPolygonEdges
)
console.log('converting circle to polygon: ')
console.log(geometry)
data.geometry = geometry
this.selectedAreaInSquareMeters = layer.getRadius() * Math.PI * Math.PI
} else if (layer instanceof L.Marker) {
this.selectedAreaInSquareMeters = 0
} else {
this.selectedAreaInSquareMeters = L.GeometryUtil.geodesicArea(
layer.getLatLngs()[0]
)
}
console.log(this.selectedAreaInSquareMeters)
this.selectedGeometry = data.geometry
}
Expand Down Expand Up @@ -582,8 +581,6 @@ class DatasetDetail extends Vue {
checkAndRestoreSavedTemporalRange() {
const savedTemporalRange = this.getSavedTemporalRange()
console.log('Saved temporal range: ')
console.log(savedTemporalRange)
if (savedTemporalRange) {
this.minTemporalRange = savedTemporalRange[0]
this.maxTemporalRange = savedTemporalRange[1]
Expand Down Expand Up @@ -625,7 +622,7 @@ class DatasetDetail extends Vue {
}
getSavedGeometry() {
const skopeGeometry = this.$warehouse.get(this.warehouseGeometryKey)
const skopeGeometry = this.$warehouse.get(this.wGeometryKey)
if (skopeGeometry) {
return JSON.parse(skopeGeometry)
}
Expand Down

0 comments on commit 8b96a50

Please sign in to comment.