[GeoMoose-users] GeoMoose and WFS

Lowell Filak filakgang at gmail.com
Tue May 6 14:04:36 PDT 2025


I have a partial fix for the issue involving incompatible coordinate
results when using GeoMoose 3.13 and a non-Mapserver WFS.
The fix can be implemented by adding the following JS to the index.html
file and then calling convertCoordinates as needed.
There may be a different fix but I didn't find it.
Hopefully this will help those looking to use the latest GM with a WFS back
end.

-- index.html
<head>
  ...
  <script type="text/javascript">
    function convertCoordinates(x3857, y3857) {
      const e = 2.7182818284;
      const X = 20037508.34;
      var lat4326 = (x3857 * 180) / X;
      var lon4326 = y3857 / (X / 180);
      const exponent = (Math.PI / 180) * lon4326;
      lon4326 = Math.atan(Math.pow(e,exponent));
      lon4326 = lon4326 / (Math.PI / 360);
      lon4326 = lon4326 - 90;
      return [lon4326, lat4326];
    }
  </script>
</head>
---

--- Select Features template example
<td>
    <a
      title="Zoom to Parcel"
      onClick="
      var bboxArray = [{{ properties.boundedBy | join }}];
      var lonlatLLArray = convertCoordinates(bboxArray[0], bboxArray[1]);
      var lonlatURArray = convertCoordinates(bboxArray[2], bboxArray[3]);

app.zoomToExtent([lonlatLLArray[0],lonlatLLArray[1],lonlatURArray[0],lonlatURArray[1]],'EPSG:4326')"
    >
      <i class="icon zoomto"></i>
...
---



> Good day,
> Thank you for all the hard work on the new version of GM.
> This question involves GM 1.13.1 on Ubuntu 24.04.2 LTS installed using the
> gm3-examples-3.13.1.zip and using QGIS Server 3.34.4 as the WMS and WFS
> back end.
>
> The WMS GetMap, GetLegendGraphic and GetFeatureInfo are working correctly.
>
> I seem to have run into an issue that I need some help resolving with the
> WFS requests.
>
> When adding a QGIS WFS layer to GM 3.13.1 the "Select Features" option does
> not work if the map-source type is set to "wfs" but will return results
> with the type set to "mapserver-wfs" and the typename set to
> "ms:qgis-layer-name".
> Using "mapserver-wfs" supplies a working solution for the initial
> GetFeature request, although I do see periodic "RequestNotWellFormed"
> exception from the server due to the "ms:" prefix.
>
> My diagnosis could be wrong, but it appears that the "mapserver-wfs" will
> trigger an assumed projection of EPSG:4326.
> With a type of "wfs" a getCode function is called that may be pointing to a
> "projection" library that is not packaged into geomoose.js and
> geomoose.min.js which results in an error.
>
> Unfortunately, the coordinates used in the results template, (for
> app.zoomToExtent), seem flipped and projected into EPSG:3857.
>
> For instance,
> Query by point is submitted to the WFS server as EPSG:4326, coordinates
> -81.93383567601884 41.02354686335107.
> The WFS reply for the feature bounding box is EPSG:4326, coordinates
> -81.934173,41.02333098 -81.93359651,41.02375282.
> The coordinates returned to the template are
> 4566696.315337524,-16915358.3614889,4566743.27435152,-16914901.003045313
>
> I can flip the coordinates in the template when making the zoomToExtent
> call but have been unsuccessful in forcing zoomToExtent to use EPSG:3857 as
> the projection.
>
> "app.zoomToExtent([-16915358.3614889,4566696.315337524,-16914901.003045313,4566743.27435152],'EPSG:3857')"
>
> Am I missing or doing something incorrect?
>
> Thank you for any help.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geomoose-users/attachments/20250506/97eb2213/attachment.htm>


More information about the GeoMoose-users mailing list