From 5fce1b0351929265e0ca4221210f9dbdb605c921 Mon Sep 17 00:00:00 2001 From: Joao Gouveia Date: Wed, 16 Aug 2017 10:20:22 +0200 Subject: [PATCH] Adds srsDimension to the pos and posList nodes when writing a WFS transaction The WFS transaction failed if the srsDimension was not present on the geometries. Unit tests have been changed to accomodate the srsDimension attribute. --- src/ol/format/gml3.js | 4 + test/spec/ol/format/gml.test.js | 103 ++++++++++++------ test/spec/ol/format/gml/topp-states-gml.xml | 32 +++--- test/spec/ol/format/wfs.test.js | 4 +- test/spec/ol/format/wfs/TransactionMulti.xml | 4 +- .../ol/format/wfs/TransactionMulti_3D.xml | 4 +- test/spec/ol/format/wfs/TransactionSrs.xml | 2 +- test/spec/ol/format/wfs/TransactionUpdate.xml | 2 +- .../wfs/TransactionUpdateMultiGeoms.xml | 4 +- 9 files changed, 97 insertions(+), 62 deletions(-) diff --git a/src/ol/format/gml3.js b/src/ol/format/gml3.js index 3c9c955763..bbfec9c59e 100644 --- a/src/ol/format/gml3.js +++ b/src/ol/format/gml3.js @@ -573,6 +573,8 @@ ol.format.GML3.prototype.SEGMENTS_PARSERS_ = { ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) { var context = objectStack[objectStack.length - 1]; var hasZ = context['hasZ']; + var srsDimension = hasZ ? 3 : 2; + node.setAttribute('srsDimension', srsDimension); var srsName = context['srsName']; var axisOrientation = 'enu'; if (srsName) { @@ -629,6 +631,8 @@ ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) { ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) { var context = objectStack[objectStack.length - 1]; var hasZ = context['hasZ']; + var srsDimension = hasZ ? 3 : 2; + node.setAttribute('srsDimension', srsDimension); var srsName = context['srsName']; // only 2d for simple features profile var points = value.getCoordinates(); diff --git a/test/spec/ol/format/gml.test.js b/test/spec/ol/format/gml.test.js index 2764eab7ab..2e450088a8 100644 --- a/test/spec/ol/format/gml.test.js +++ b/test/spec/ol/format/gml.test.js @@ -353,7 +353,7 @@ describe('ol.format.GML3', function() { var text = '' + - ' 1 2' + + ' 1 2' + ''; var g = readGeometry(format, text); expect(g).to.be.an(ol.geom.Point); @@ -423,7 +423,7 @@ describe('ol.format.GML3', function() { var text = '' + - ' 2 1' + + ' 2 1' + ''; var g = readGeometry(formatWGS84, text); expect(g).to.be.an(ol.geom.Point); @@ -440,7 +440,7 @@ describe('ol.format.GML3', function() { var text = '' + - ' 1 2 3 4' + + ' 1 2 3 4' + ''; var g = readGeometry(format, text); expect(g).to.be.an(ol.geom.LineString); @@ -479,7 +479,7 @@ describe('ol.format.GML3', function() { var text = '' + - ' 2 1 4 3' + + ' 2 1 4 3' + ''; var g = readGeometry(formatWGS84, text); expect(g).to.be.an(ol.geom.LineString); @@ -498,7 +498,7 @@ describe('ol.format.GML3', function() { var text = '' + - ' -90 -180 90 180' + + ' -90 -180 90 180' + ''; var g = readGeometry(format, text); expect(g).to.be.an(ol.geom.LineString); @@ -512,7 +512,7 @@ describe('ol.format.GML3', function() { var text = '' + - ' -90 -180' + + ' -90 -180' + ''; var g = readGeometry(format, text); expect(g).to.be.an(ol.geom.Point); @@ -531,7 +531,8 @@ describe('ol.format.GML3', function() { ' ' + ' ' + - ' 38.9661 -77.0081 38.9931 -77.0421 ' + + ' ' + + ' 38.9661 -77.0081 38.9931 -77.0421 ' + ' 38.9321 -77.1221 38.9151 -77.0781 38.8861 ' + ' -77.0671 38.8621 -77.0391 38.8381 -77.0401 ' + ' 38.8291 -77.0451 38.8131 -77.0351 38.7881 ' + @@ -575,7 +576,7 @@ describe('ol.format.GML3', function() { var text = '' + - ' 1 2 3 4 5 6 1 2' + + ' 1 2 3 4 5 6 1 2' + ''; var g = readGeometry(format, text); expect(g).to.be.an(ol.geom.LinearRing); @@ -595,17 +596,17 @@ describe('ol.format.GML3', function() { ' srsName="CRS:84">' + ' ' + ' ' + - ' 1 2 3 2 3 4 1 2' + + ' 1 2 3 2 3 4 1 2' + ' ' + ' ' + ' ' + ' ' + - ' 2 3 2 5 4 5 2 3' + + ' 2 3 2 5 4 5 2 3' + ' ' + ' ' + ' ' + ' ' + - ' 3 4 3 6 5 6 3 4' + + ' 3 4 3 6 5 6 3 4' + ' ' + ' ' + ''; @@ -630,17 +631,23 @@ describe('ol.format.GML3', function() { ' ' + ' ' + ' ' + - ' 1 2 3 2 3 4 1 2' + + ' ' + + ' 1 2 3 2 3 4 1 2' + + ' ' + ' ' + ' ' + ' ' + ' ' + - ' 2 3 2 5 4 5 2 3' + + ' ' + + ' 2 3 2 5 4 5 2 3' + + ' ' + ' ' + ' ' + ' ' + ' ' + - ' 3 4 3 6 5 6 3 4' + + ' ' + + ' 3 4 3 6 5 6 3 4' + + ' ' + ' ' + ' ' + ' ' + @@ -666,7 +673,7 @@ describe('ol.format.GML3', function() { ' srsName="CRS:84">' + ' ' + ' ' + - ' 1 2 3 4' + + ' 1 2 3 4' + ' ' + ' ' + ''; @@ -703,17 +710,17 @@ describe('ol.format.GML3', function() { ' srsName="CRS:84">' + ' ' + ' ' + - ' 1 2' + + ' 1 2' + ' ' + ' ' + ' ' + ' ' + - ' 2 3' + + ' 2 3' + ' ' + ' ' + ' ' + ' ' + - ' 3 4' + + ' 3 4' + ' ' + ' ' + ''; @@ -755,12 +762,12 @@ describe('ol.format.GML3', function() { ' srsName="CRS:84">' + ' ' + ' ' + - ' 1 2 2 3' + + ' 1 2 2 3' + ' ' + ' ' + ' ' + ' ' + - ' 3 4 4 5' + + ' 3 4 4 5' + ' ' + ' ' + ''; @@ -804,17 +811,23 @@ describe('ol.format.GML3', function() { ' ' + ' ' + ' ' + - ' 1 2 3 2 3 4 1 2' + + ' ' + + ' 1 2 3 2 3 4 1 2' + + ' ' + ' ' + ' ' + ' ' + ' ' + - ' 2 3 2 5 4 5 2 3' + + ' ' + + ' 2 3 2 5 4 5 2 3' + + ' ' + ' ' + ' ' + ' ' + ' ' + - ' 3 4 3 6 5 6 3 4' + + ' ' + + ' 3 4 3 6 5 6 3 4' + + ' ' + ' ' + ' ' + ' ' + @@ -823,7 +836,9 @@ describe('ol.format.GML3', function() { ' ' + ' ' + ' ' + - ' 1 2 3 2 3 4 1 2' + + ' ' + + ' 1 2 3 2 3 4 1 2' + + ' ' + ' ' + ' ' + ' ' + @@ -892,12 +907,12 @@ describe('ol.format.GML3', function() { ' srsName="CRS:84">' + ' ' + ' ' + - ' 1 2 2 3' + + ' 1 2 2 3' + ' ' + ' ' + ' ' + ' ' + - ' 3 4 4 5' + + ' 3 4 4 5' + ' ' + ' ' + ''; @@ -917,7 +932,7 @@ describe('ol.format.GML3', function() { ' ' + ' ' + ' ' + - ' 1 2 2 3' + + ' 1 2 2 3' + ' ' + ' ' + ' ' + @@ -926,7 +941,7 @@ describe('ol.format.GML3', function() { ' ' + ' ' + ' ' + - ' 3 4 4 5' + + ' 3 4 4 5' + ' ' + ' ' + ' ' + @@ -953,17 +968,23 @@ describe('ol.format.GML3', function() { ' ' + ' ' + ' ' + - ' 1 2 3 2 3 4 1 2' + + ' ' + + ' 1 2 3 2 3 4 1 2' + + ' ' + ' ' + ' ' + ' ' + ' ' + - ' 2 3 2 5 4 5 2 3' + + ' ' + + ' 2 3 2 5 4 5 2 3' + + ' ' + ' ' + ' ' + ' ' + ' ' + - ' 3 4 3 6 5 6 3 4' + + ' ' + + ' 3 4 3 6 5 6 3 4' + + ' ' + ' ' + ' ' + ' ' + @@ -972,7 +993,9 @@ describe('ol.format.GML3', function() { ' ' + ' ' + ' ' + - ' 1 2 3 2 3 4 1 2' + + ' ' + + ' 1 2 3 2 3 4 1 2' + + ' ' + ' ' + ' ' + ' ' + @@ -1041,17 +1064,23 @@ describe('ol.format.GML3', function() { ' ' + ' ' + ' ' + - ' 1 2 3 2 3 4 1 2' + + ' ' + + ' 1 2 3 2 3 4 1 2' + + ' ' + ' ' + ' ' + ' ' + ' ' + - ' 2 3 2 5 4 5 2 3' + + ' ' + + ' 2 3 2 5 4 5 2 3' + + ' ' + ' ' + ' ' + ' ' + ' ' + - ' 3 4 3 6 5 6 3 4' + + ' ' + + ' 3 4 3 6 5 6 3 4' + + ' ' + ' ' + ' ' + ' ' + @@ -1064,7 +1093,9 @@ describe('ol.format.GML3', function() { ' ' + ' ' + ' ' + - ' 1 2 3 2 3 4 1 2' + + ' ' + + ' 1 2 3 2 3 4 1 2' + + ' ' + ' ' + ' ' + ' ' + diff --git a/test/spec/ol/format/gml/topp-states-gml.xml b/test/spec/ol/format/gml/topp-states-gml.xml index 2090909512..3919cf8c13 100644 --- a/test/spec/ol/format/gml/topp-states-gml.xml +++ b/test/spec/ol/format/gml/topp-states-gml.xml @@ -10,7 +10,7 @@ - 37.5101 -88.0711 37.5831 -88.1341 37.6281 -88.1571 + 37.5101 -88.0711 37.5831 -88.1341 37.6281 -88.1571 37.6601 -88.1591 37.7001 -88.1331 37.7351 -88.0721 37.8051 -88.0351 37.8171 -88.0861 37.8311 -88.0891 37.8271 -88.0421 37.8431 -88.0341 37.8671 -88.0751 37.8951 -88.1011 37.9061 @@ -141,7 +141,7 @@ - 38.9661 -77.0081 38.9931 -77.0421 38.9321 -77.1221 + 38.9661 -77.0081 38.9931 -77.0421 38.9321 -77.1221 38.9151 -77.0781 38.8861 -77.0671 38.8621 -77.0391 38.8381 -77.0401 38.8291 -77.0451 38.8131 -77.0351 38.7881 -77.0451 38.8891 -76.9111 38.9661 -77.0081 @@ -182,7 +182,7 @@ - 38.5571 -75.7071 38.4631 -75.6991 38.4551 -75.3501 + 38.5571 -75.7071 38.4631 -75.6991 38.4551 -75.3501 38.4501 -75.0931 38.4491 -75.0681 38.4491 -75.0451 38.7991 -75.0831 38.8081 -75.1901 38.9451 -75.3071 39.0121 -75.3241 39.0731 -75.3971 39.2571 -75.4021 39.3661 -75.5151 39.4631 @@ -230,7 +230,7 @@ - 38.4801 -79.2311 38.6581 -79.1271 38.6631 -79.1211 + 38.4801 -79.2311 38.6581 -79.1271 38.6631 -79.1211 38.6591 -79.0881 38.7071 -79.0871 38.7611 -79.0561 38.7901 -79.0551 38.7991 -79.0331 38.8461 -78.9871 38.7631 -78.8661 38.8331 -78.8161 38.8801 -78.7931 38.9111 -78.7491 38.9291 @@ -381,7 +381,7 @@ - 38.6491 -75.7111 38.8301 -75.7241 39.1411 -75.7521 + 38.6491 -75.7111 38.8301 -75.7241 39.1411 -75.7521 39.2471 -75.7611 39.2951 -75.7641 39.3831 -75.7721 39.7231 -75.7911 39.7221 -76.1391 39.7211 -76.2331 39.7201 -76.5701 39.7211 -76.7901 39.7201 -76.9971 39.7201 -77.2211 39.7191 @@ -459,7 +459,7 @@ - 38.9071 -76.2931 38.9491 -76.2731 38.9231 -76.2461 + 38.9071 -76.2931 38.9491 -76.2731 38.9231 -76.2461 38.9781 -76.2481 39.0401 -76.2991 38.9581 -76.3561 38.8541 -76.3751 38.8751 -76.3291 38.9241 -76.3421 38.9121 -76.3221 38.9411 -76.3141 38.9561 -76.3391 38.9671 -76.2941 38.9071 @@ -472,7 +472,7 @@ - 38.4491 -75.0681 38.3221 -75.0871 38.4491 -75.0451 + 38.4491 -75.0681 38.3221 -75.0871 38.4491 -75.0451 38.4491 -75.0681 @@ -482,7 +482,7 @@ - 38.0271 -75.2701 38.0281 -75.2421 38.1241 -75.1731 + 38.0271 -75.2701 38.0281 -75.2421 38.1241 -75.1731 38.3201 -75.0941 38.2041 -75.1641 38.0941 -75.2091 38.0371 -75.2441 38.0271 -75.2701 @@ -522,7 +522,7 @@ - 37.6411 -102.0431 37.7341 -102.0431 38.2531 -102.0451 + 37.6411 -102.0431 37.7341 -102.0431 38.2531 -102.0451 38.2631 -102.0451 38.6151 -102.0471 38.6921 -102.0471 39.0361 -102.0481 39.1261 -102.0471 39.5621 -102.0481 39.5681 -102.0481 39.9981 -102.0511 40.3421 -102.0471 40.4311 -102.0471 40.6971 @@ -576,7 +576,7 @@ - 36.6551 -86.5101 36.6501 -86.4151 36.6431 -86.1991 + 36.6551 -86.5101 36.6501 -86.4151 36.6431 -86.1991 36.6331 -85.9801 36.6261 -85.7851 36.6181 -85.4371 36.6261 -85.3001 36.6251 -85.2721 36.6201 -84.9981 36.6051 -84.7911 36.6051 -84.7811 36.5951 -84.2561 36.5951 -84.2541 36.5921 @@ -684,7 +684,7 @@ - 36.4981 -89.5331 36.4981 -89.4751 36.5041 -89.4811 + 36.4981 -89.5331 36.4981 -89.4751 36.5041 -89.4811 36.5251 -89.4711 36.5471 -89.4811 36.5591 -89.4931 36.5641 -89.5301 36.5571 -89.5561 36.5411 -89.5681 36.5181 -89.5661 36.4981 -89.5331 @@ -725,7 +725,7 @@ - 37.0011 -95.0711 37.0001 -95.0321 36.9961 -94.6201 + 37.0011 -95.0711 37.0001 -95.0321 36.9961 -94.6201 37.0601 -94.6201 37.3271 -94.6181 37.3601 -94.6181 37.6501 -94.6181 37.6791 -94.6191 38.0301 -94.6161 38.0551 -94.6171 38.3921 -94.6181 38.4711 -94.6181 38.7371 -94.6121 38.8371 @@ -798,7 +798,7 @@ - 36.5461 -79.1441 36.5431 -78.7961 36.5461 -78.7371 + 36.5461 -79.1441 36.5431 -78.7961 36.5461 -78.7371 36.5411 -78.4581 36.5451 -78.3211 36.5521 -78.0511 36.5521 -77.8981 36.5531 -77.7631 36.5531 -77.3201 36.5561 -77.1771 36.5541 -76.9241 36.5541 -76.9211 36.5551 -76.5631 36.5551 @@ -910,7 +910,7 @@ - 38.0271 -75.2701 37.9181 -75.3461 37.9001 -75.3781 + 38.0271 -75.2701 37.9181 -75.3461 37.9001 -75.3781 37.9011 -75.3441 37.8751 -75.3861 37.8881 -75.3391 37.9621 -75.2981 38.0281 -75.2421 38.0271 -75.2701 @@ -921,7 +921,7 @@ - 37.5521 -75.8671 37.5561 -75.9301 37.5211 -75.9541 + 37.5521 -75.8671 37.5561 -75.9301 37.5211 -75.9541 37.4791 -75.9651 37.4841 -75.9341 37.3081 -76.0181 37.1261 -75.9701 37.1421 -75.9311 37.3671 -75.8971 37.4181 -75.8261 37.4081 -75.7901 37.4261 -75.8201 37.4691 -75.8131 37.4931 @@ -968,7 +968,7 @@ - 36.9531 -89.1041 36.9771 -89.1071 36.9881 -89.1291 + 36.9531 -89.1041 36.9771 -89.1071 36.9881 -89.1291 36.9861 -89.1931 37.0281 -89.2101 37.0411 -89.2371 37.0871 -89.2641 37.0911 -89.2841 37.0851 -89.3031 37.0601 -89.3091 37.0271 -89.2641 37.0081 -89.2621 36.9991 -89.2821 37.0091 diff --git a/test/spec/ol/format/wfs.test.js b/test/spec/ol/format/wfs.test.js index 503427f078..5f1368aaa0 100644 --- a/test/spec/ol/format/wfs.test.js +++ b/test/spec/ol/format/wfs.test.js @@ -524,7 +524,7 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ' ' + - ' ' + + ' ' + ' 10 20 10 25 15 25 15 20 10 20' + ' ' + ' ' + @@ -561,7 +561,7 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ' ' + - ' ' + + ' ' + ' 10 20 10 25 15 25 15 20 10 20' + ' ' + ' ' + diff --git a/test/spec/ol/format/wfs/TransactionMulti.xml b/test/spec/ol/format/wfs/TransactionMulti.xml index 1154cb38c0..a9b1953080 100644 --- a/test/spec/ol/format/wfs/TransactionMulti.xml +++ b/test/spec/ol/format/wfs/TransactionMulti.xml @@ -5,7 +5,7 @@ - 1 2 + 1 2 @@ -20,7 +20,7 @@ - 1 2 + 1 2 diff --git a/test/spec/ol/format/wfs/TransactionMulti_3D.xml b/test/spec/ol/format/wfs/TransactionMulti_3D.xml index cb0ab3dd31..a630e78d95 100644 --- a/test/spec/ol/format/wfs/TransactionMulti_3D.xml +++ b/test/spec/ol/format/wfs/TransactionMulti_3D.xml @@ -5,7 +5,7 @@ - 1 2 3 + 1 2 3 @@ -20,7 +20,7 @@ - 1 2 3 + 1 2 3 diff --git a/test/spec/ol/format/wfs/TransactionSrs.xml b/test/spec/ol/format/wfs/TransactionSrs.xml index 14d109046e..ed409a59a0 100644 --- a/test/spec/ol/format/wfs/TransactionSrs.xml +++ b/test/spec/ol/format/wfs/TransactionSrs.xml @@ -1 +1 @@ --5178372.1885436 1992365.7775042 -4434792.7774889 1601008.1927386 -4043435.1927233 2148908.8114105xyz +-5178372.1885436 1992365.7775042 -4434792.7774889 1601008.1927386 -4043435.1927233 2148908.8114105xyz diff --git a/test/spec/ol/format/wfs/TransactionUpdate.xml b/test/spec/ol/format/wfs/TransactionUpdate.xml index 9155d91dfe..7f3df0ba1f 100644 --- a/test/spec/ol/format/wfs/TransactionUpdate.xml +++ b/test/spec/ol/format/wfs/TransactionUpdate.xml @@ -8,7 +8,7 @@ - -12279454 6741885 -12064207 + -12279454 6741885 -12064207 6732101 -11941908 6595126 -12240318 6507071 -12416429 6604910 diff --git a/test/spec/ol/format/wfs/TransactionUpdateMultiGeoms.xml b/test/spec/ol/format/wfs/TransactionUpdateMultiGeoms.xml index a65488f311..e3ba54552f 100644 --- a/test/spec/ol/format/wfs/TransactionUpdateMultiGeoms.xml +++ b/test/spec/ol/format/wfs/TransactionUpdateMultiGeoms.xml @@ -8,7 +8,7 @@ - -12279454 6741885 -12064207 + -12279454 6741885 -12064207 6732101 -11941908 6595126 -12240318 6507071 -12416429 6604910 @@ -20,7 +20,7 @@ - -12000000 6700000 -12000001 6700001 -12000002 6700002 + -12000000 6700000 -12000001 6700001 -12000002 6700002