Skip to content

Commit

Permalink
fix: Draw shapefile exports as EPSG:31468 instead of WGS84 (needs work)
Browse files Browse the repository at this point in the history
This is temporary; exports all shapefiles as EPSG:31468 instead of
correctly auto-sensing the proper CRS. That will come in a future update.
  • Loading branch information
billyc committed Jul 9, 2021
1 parent 3d7e25f commit 9176141
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/components/DrawingTool/DrawingTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ de:
<script lang="ts">
import { Vue, Component, Watch, Prop } from 'vue-property-decorator'
import { GeoJsonLayer, ScatterplotLayer } from '@deck.gl/layers'
import proj4 from 'proj4'
import ShapeWrite from 'shp-write'
import LayerManager from '@/util/LayerManager'
Expand Down Expand Up @@ -143,9 +144,12 @@ export default class VueComponent extends Vue {
this.points = []
this.updateLayers()
// TEMP: convert to EPSG:31468 for VW demo
const convertPolygons = this.convertPolygons('EPSG:31468')
const geojson = {
type: 'FeatureCollection',
features: this.polygons,
features: convertPolygons,
}
ShapeWrite.download(geojson, {
Expand All @@ -160,6 +164,31 @@ export default class VueComponent extends Vue {
this.startNewPolygon()
}
private convertPolygons(crs: string) {
const convertedPolygons: any[] = []
console.log('CONVERTING')
console.log(this.polygons)
for (const p of this.polygons) {
const convertedPolygon = {
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: [[]] as any[],
},
}
for (const point of p.geometry.coordinates[0]) {
console.log(point)
const pointConverted = proj4('WGS84', crs, point)
convertedPolygon.geometry.coordinates[0].push(pointConverted)
}
convertedPolygons.push(convertedPolygon)
}
console.log({ convertedPolygons })
return convertedPolygons
}
private cancel() {
this.hint = this.$t('hint')
this.clearShapes()
Expand Down

0 comments on commit 9176141

Please sign in to comment.