Skip to content

Commit ae0fc4b

Browse files
more fixes for the WFS display layer.
Ensure projections are set properly when given src-srs
1 parent 8ebfc01 commit ae0fc4b

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

examples/desktop/mapbook.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,32 @@
88
<layer name="usng-grid" status="off" />
99
</map-source>
1010

11+
<map-source name="issue542" type="wfs" src-proj="EPSG:4326" title="Issue 542">
12+
<url>https://mrdata.usgs.gov/wfs/sgmc2</url>
13+
<param name="typename" value="ms:Structure"/>
14+
<!--
15+
<param name="cross-origin" value="anonymous"/>
16+
<param name="srsname" value="EPSG:4326"/>
17+
-->
18+
<layer name="Structure" >
19+
<style><![CDATA[
20+
{
21+
"circle-radius": 4,
22+
"circle-color": "#fec44f",
23+
"fill-color": "#fec44f",
24+
"circle-stroke-color": "#d95f0e",
25+
"line-color": "blue",
26+
"line-width": 2,
27+
"fill-opacity": 0.20,
28+
"line-opacity": 0.80,
29+
"text-field_COMMENTED-OUT": "{OWNER_NAME}",
30+
"text-color": "#000000"
31+
}
32+
]]></style>
33+
<template name="identify" auto="true" />
34+
</layer>
35+
</map-source>
36+
1137
<map-source name="sketch" type="vector" title="Drawing and Markup">
1238
<layer name="default" selectable="true" status="on">
1339
<style><![CDATA[
@@ -478,6 +504,8 @@
478504
draw-point="true" draw-line="true" draw-polygon="true"
479505
draw-modify="true" draw-remove="true" draw-edit="true" />
480506

507+
<layer src="issue542/Structure" />
508+
481509
<group title="Overlays" expand="true" tip="Layers that sit above the basemaps">
482510
<group title="County Layers">
483511
<metadata>https://raw.githubusercontent.com/geomoose/gm3-demo-data/main/demo/parcels/LICENSE</metadata>

src/gm3/components/map/layers/vector.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ import { tile, bbox } from "ol/loadingstrategy";
4141
import VectorSource from "ol/source/Vector";
4242
import VectorLayer from "ol/layer/Vector";
4343
import { createXYZ } from "ol/tilegrid";
44+
import { transformExtent } from "ol/proj";
4445
import { getEditStyle } from "./edit";
4546
import { EDIT_LAYER_NAME } from "../../../defaults";
47+
import { getQueryProjection } from "./wfs";
4648

4749
// WARNING! This is a monkey patch in order to
4850
// allow rendering labels outside of a polygon's
@@ -76,25 +78,37 @@ function defineSource(mapSource) {
7678
format = GeoJSONFormat;
7779
}
7880

81+
// TODO: Ensure this gets the real map projection when
82+
// the code supports alternative projections.
83+
const mapProjection = "EPSG:3857";
84+
const queryProjection = getQueryProjection(mapSource, mapProjection);
85+
7986
return {
80-
format: new format({}),
81-
projection: "EPSG:4326",
87+
format: new format({
88+
srsName: queryProjection,
89+
}),
8290
url: function (extent) {
8391
if (typeof mapSource.params.typename === "undefined") {
8492
console.error(
8593
'No "typename" param defined for a WFS layer. This will fail.'
8694
);
8795
}
8896

97+
const queryExtent = transformExtent(
98+
extent,
99+
mapProjection,
100+
queryProjection
101+
);
102+
89103
const urlParams = Object.assign(
90104
{},
91105
{
92-
srsname: "EPSG:3857",
106+
srs: queryProjection,
93107
outputFormat: outputFormat,
94108
service: "WFS",
95109
version: "1.1.0",
96110
request: "GetFeature",
97-
bbox: extent.concat("EPSG:3857").join(","),
111+
bbox: queryExtent,
98112
},
99113
mapSource.params
100114
);

0 commit comments

Comments
 (0)