From df5c21aaef5a8b42238c2b3427c71fc04197fc54 Mon Sep 17 00:00:00 2001 From: Tibet Sprague Date: Fri, 1 Jul 2022 13:22:56 -0700 Subject: [PATCH 1/2] Fix saving of empty geoShape on groups --- api/models/Group.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/api/models/Group.js b/api/models/Group.js index d4066bb06..430bbe879 100644 --- a/api/models/Group.js +++ b/api/models/Group.js @@ -30,18 +30,6 @@ module.exports = bookshelf.Model.extend(merge({ requireFetch: false, hasTimestamps: true, - format(attributes) { - const st = knexPostgis(bookshelf.knex) - - // Make sure geometry column goes into the database correctly, converting from GeoJSON - const { geo_shape } = attributes - if (geo_shape) { - attributes.geo_shape = st.geomFromGeoJSON(geo_shape) - } - - return attributes - }, - parse(response) { const st = knexPostgis(bookshelf.knex) @@ -393,6 +381,14 @@ module.exports = bookshelf.Model.extend(merge({ saneAttrs.location_id = isEmpty(saneAttrs.location_id) ? null : saneAttrs.location_id + // Make sure geometry column goes into the database correctly, converting from GeoJSON + if (!isEmpty(attributes.geo_shape)) { + const st = knexPostgis(bookshelf.knex) + saneAttrs.geo_shape = st.geomFromGeoJSON(attributes.geo_shape) + } else { + saneAttrs.geo_shape = null + } + // If a new location is being passed in but not a new location_id then we geocode on the server if (changes.location && changes.location !== this.get('location') && !changes.location_id) { await Queue.classMethod('Group', 'geocodeLocation', { groupId: this.id }) From c31e383735bbf1dc36ee67b2f9bf7c45c1f3c683 Mon Sep 17 00:00:00 2001 From: Tibet Sprague Date: Wed, 6 Jul 2022 11:19:13 -0700 Subject: [PATCH 2/2] Update to version 4.1.5 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c187eb5c..9c3778fd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## [4.1.5] - 2022-07-05 + +### Fixed +- Saving of groups with empty group shapes + ## [4.1.4] - 2022-06-20 ### Fixed diff --git a/package.json b/package.json index 9b50b8234..5f3df1c84 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "author": "Tibet Sprague ", "license": "GNU AFFERO GENERAL PUBLIC LICENSE v3", "private": true, - "version": "4.1.4", + "version": "4.1.5", "repository": { "type": "git", "url": "git://github.com/Hylozoic/hylo-node.git"