changeset 2755:2b4727a32ce6

Stretches import: allow ISRS_from > ISRS_to. The order constraint on isrsranges are arbitrary and should be satisfied by the WAMOS back end not by the user data.
author Sascha Wilde <wilde@intevation.de>
date Thu, 21 Mar 2019 13:47:57 +0100
parents d0f6c222f4f9
children ee2530ee1c0b
files client/src/components/ImportStretches.vue pkg/imports/st.go
diffstat 2 files changed, 21 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/ImportStretches.vue	Thu Mar 21 13:24:49 2019 +0100
+++ b/client/src/components/ImportStretches.vue	Thu Mar 21 13:47:57 2019 +0100
@@ -151,11 +151,6 @@
               </small>
             </span>
           </div>
-          <span class="text-left text-danger">
-            <small v-if="!pointsValid">
-              <translate>Startpoint is not before endpoint.</translate>
-            </small>
-          </span>
         </div>
         <div
           v-if="!editExistingStretch"
@@ -338,13 +333,6 @@
       }
       return result;
     },
-    pointsValid() {
-      if (!this.startrhm || !this.endrhm) return true;
-      const start = this.startrhm.replace(/\D+/g, "") * 1;
-      const end = this.endrhm.replace(/\D+/g, "") * 1;
-      const result = start < end;
-      return result;
-    }
   },
   watch: {
     identifiedFeatures() {
@@ -520,7 +508,6 @@
     },
     save() {
       this.validate();
-      if (!this.pointsValid) return;
       if (
         !this.id ||
         !this.startrhm ||
--- a/pkg/imports/st.go	Thu Mar 21 13:24:49 2019 +0100
+++ b/pkg/imports/st.go	Thu Mar 21 13:47:57 2019 +0100
@@ -77,16 +77,27 @@
 	stInsertSQL = `
 WITH r AS (
   SELECT isrsrange(
-	( $1::char(2),
-	  $2::char(3),
-	  $3::char(5),
-	  $4::char(5),
-	  $5::int),
-	( $6::char(2),
-	  $7::char(3),
-	  $8::char(5),
-	  $9::char(5),
-	  $10::int)) AS r
+    least(($1::char(2),
+           $2::char(3),
+           $3::char(5),
+           $4::char(5),
+           $5::int)::isrs,
+          ($6::char(2),
+           $7::char(3),
+           $8::char(5),
+           $9::char(5),
+           $10::int)::isrs),
+    greatest(($1::char(2),
+              $2::char(3),
+              $3::char(5),
+              $4::char(5),
+              $5::int)::isrs,
+             ($6::char(2),
+              $7::char(3),
+              $8::char(5),
+              $9::char(5),
+              $10::int)::isrs)
+    ) AS r
 )
 INSERT INTO waterway.stretches (
   name,