Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/haninge-geodata/origo int…
Browse files Browse the repository at this point in the history
…o wfs-qgis-filter-support
  • Loading branch information
MattiasSp committed Feb 22, 2024
2 parents ae5ae79 + 8e9f2ba commit 8af3134
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 93 deletions.
43 changes: 22 additions & 21 deletions data/origo-cities-3857.geojson
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@
"name": "origo-cities-3857",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::3857" } },
"features": [
{ "type": "Feature", "properties": { "id": 1, "name": "Karlstad" }, "geometry": { "type": "Point", "coordinates": [ 1503136, 8262205 ] } },
{ "type": "Feature", "properties": { "id": 2, "name": "Hallstahammar" }, "geometry": { "type": "Point", "coordinates": [ 1807133, 8313751 ] } },
{ "type": "Feature", "properties": { "id": 4, "name": "Eskilstuna" }, "geometry": { "type": "Point", "coordinates": [ 1836807, 8260572 ] } },
{ "type": "Feature", "properties": { "id": 5, "name": "Strängnäs" }, "geometry": { "type": "Point", "coordinates": [ 1894581, 8261118 ] } },
{ "type": "Feature", "properties": { "id": 6, "name": "Enköping" }, "geometry": { "type": "Point", "coordinates": [ 1901643, 8320134 ] } },
{ "type": "Feature", "properties": { "id": 7, "name": "Sigtuna" }, "geometry": { "type": "Point", "coordinates": [ 1986473, 8315061 ] } },
{ "type": "Feature", "properties": { "id": 8, "name": "Hudiksvall" }, "geometry": { "type": "Point", "coordinates": [ 1904063, 8794995 ] } },
{ "type": "Feature", "properties": { "id": 9, "name": "Nordanstig" }, "geometry": { "type": "Point", "coordinates": [ 1898886, 8855279 ] } },
{ "type": "Feature", "properties": { "id": 10, "name": "Ånge" }, "geometry": { "type": "Point", "coordinates": [ 1743306, 8984535 ] } },
{ "type": "Feature", "properties": { "id": 11, "name": "Sundsvall" }, "geometry": { "type": "Point", "coordinates": [ 1926687, 8952900 ] } },
{ "type": "Feature", "properties": { "id": 12, "name": "Timrå" }, "geometry": { "type": "Point", "coordinates": [ 1928943, 8976191 ] } },
{ "type": "Feature", "properties": { "id": 13, "name": "Härnösand" }, "geometry": { "type": "Point", "coordinates": [ 1996548, 9010642 ] } },
{ "type": "Feature", "properties": { "id": 14, "name": "Kramfors" }, "geometry": { "type": "Point", "coordinates": [ 1979837, 9083261 ] } },
{ "type": "Feature", "properties": { "id": 15, "name": "Sollefteå" }, "geometry": { "type": "Point", "coordinates": [ 1922083, 9141271 ] } },
{ "type": "Feature", "properties": { "id": 16, "name": "Örnsköldsvik" }, "geometry": { "type": "Point", "coordinates": [ 2082559, 9171375 ] } },
{ "type": "Feature", "properties": { "id": 17, "name": "Norberg" }, "geometry": { "type": "Point", "coordinates": [ 1773055, 8414134 ] } },
{ "type": "Feature", "properties": { "id": 18, "name": "Avesta" }, "geometry": { "type": "Point", "coordinates": [ 1801204, 8431717 ] } },
{ "type": "Feature", "properties": { "id": 19, "name": "Fagersta" }, "geometry": { "type": "Point", "coordinates": [ 1758647, 8400343 ] } },
{ "type": "Feature", "properties": { "id": 20, "name": "Kristianstad" }, "geometry": { "type": "Point", "coordinates": [ 1575633, 7565358 ] } },
{ "type": "Feature", "properties": { "id": 21, "name": "Mora" }, "geometry": { "type": "Point", "coordinates": [ 1618908, 8627715 ] } },
{ "type": "Feature", "properties": { "id": 22, "name": "Orsa" }, "geometry": { "type": "Point", "coordinates": [ 1627705, 8653421 ] } }
{ "type": "Feature", "properties": { "id": 1, "name": "Karlstad" }, "geometry": { "type": "Point", "coordinates": [ 1503136.0, 8262205.0 ] } },
{ "type": "Feature", "properties": { "id": 2, "name": "Hallstahammar" }, "geometry": { "type": "Point", "coordinates": [ 1807133.0, 8313751.0 ] } },
{ "type": "Feature", "properties": { "id": 4, "name": "Eskilstuna" }, "geometry": { "type": "Point", "coordinates": [ 1836807.0, 8260572.0 ] } },
{ "type": "Feature", "properties": { "id": 5, "name": "Strängnäs" }, "geometry": { "type": "Point", "coordinates": [ 1894581.0, 8261118.0 ] } },
{ "type": "Feature", "properties": { "id": 6, "name": "Enköping" }, "geometry": { "type": "Point", "coordinates": [ 1901643.0, 8320134.0 ] } },
{ "type": "Feature", "properties": { "id": 7, "name": "Sigtuna" }, "geometry": { "type": "Point", "coordinates": [ 1986473.0, 8315061.0 ] } },
{ "type": "Feature", "properties": { "id": 8, "name": "Hudiksvall" }, "geometry": { "type": "Point", "coordinates": [ 1904063.0, 8794995.0 ] } },
{ "type": "Feature", "properties": { "id": 9, "name": "Nordanstig" }, "geometry": { "type": "Point", "coordinates": [ 1898886.0, 8855279.0 ] } },
{ "type": "Feature", "properties": { "id": 10, "name": "Ånge" }, "geometry": { "type": "Point", "coordinates": [ 1743306.0, 8984535.0 ] } },
{ "type": "Feature", "properties": { "id": 11, "name": "Sundsvall" }, "geometry": { "type": "Point", "coordinates": [ 1926687.0, 8952900.0 ] } },
{ "type": "Feature", "properties": { "id": 12, "name": "Timrå" }, "geometry": { "type": "Point", "coordinates": [ 1928943.0, 8976191.0 ] } },
{ "type": "Feature", "properties": { "id": 13, "name": "Härnösand" }, "geometry": { "type": "Point", "coordinates": [ 1996548.0, 9010642.0 ] } },
{ "type": "Feature", "properties": { "id": 14, "name": "Kramfors" }, "geometry": { "type": "Point", "coordinates": [ 1979837.0, 9083261.0 ] } },
{ "type": "Feature", "properties": { "id": 15, "name": "Sollefteå" }, "geometry": { "type": "Point", "coordinates": [ 1922083.0, 9141271.0 ] } },
{ "type": "Feature", "properties": { "id": 16, "name": "Örnsköldsvik" }, "geometry": { "type": "Point", "coordinates": [ 2082559.0, 9171375.0 ] } },
{ "type": "Feature", "properties": { "id": 17, "name": "Norberg" }, "geometry": { "type": "Point", "coordinates": [ 1773055.0, 8414134.0 ] } },
{ "type": "Feature", "properties": { "id": 18, "name": "Avesta" }, "geometry": { "type": "Point", "coordinates": [ 1801204.0, 8431717.0 ] } },
{ "type": "Feature", "properties": { "id": 19, "name": "Fagersta" }, "geometry": { "type": "Point", "coordinates": [ 1758647.0, 8400343.0 ] } },
{ "type": "Feature", "properties": { "id": 20, "name": "Kristianstad" }, "geometry": { "type": "Point", "coordinates": [ 1575633.0, 7565358.0 ] } },
{ "type": "Feature", "properties": { "id": 21, "name": "Mora" }, "geometry": { "type": "Point", "coordinates": [ 1618908.0, 8627715.0 ] } },
{ "type": "Feature", "properties": { "id": 22, "name": "Orsa" }, "geometry": { "type": "Point", "coordinates": [ 1627705.0, 8653421.0 ] } },
{ "type": "Feature", "properties": { "id": 23, "name": "Tomelilla" }, "geometry": { "type": "Point", "coordinates": [ 1553290.0, 7467849.0 ] } }
]
}
5 changes: 2 additions & 3 deletions data/origo-mask-3857.geojson

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/controls/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ const Search = function Search(options = {}) {
.then((res) => {
if (res.length > 0) {
const featLayerName = layer.get('name');
featureInfo.showFeatureInfo({ feature: res, layerName: featLayerName });
featureInfo.showFeatureInfo({ feature: res, layerName: featLayerName }, { maxZoomLevel });
}
});
});
Expand Down Expand Up @@ -391,7 +391,7 @@ const Search = function Search(options = {}) {
.then((res) => {
if (res.length > 0) {
const featureLayerName = layer.get('name');
featureInfo.showFeatureInfo({ feature: res, layerName: featureLayerName });
featureInfo.showFeatureInfo({ feature: res, layerName: featureLayerName }, { maxZoomLevel });
}
});
});
Expand Down
20 changes: 16 additions & 4 deletions src/featureinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const Featureinfo = function Featureinfo(options = {}) {
let popup;
let viewer;
let selectionManager;
let textHtmlHandler;
/** The featureinfo component itself */
let component;

Expand Down Expand Up @@ -296,6 +297,10 @@ const Featureinfo = function Featureinfo(options = {}) {
}
};

const addTextHtmlHandler = function addTextHtmlHandler(func) {
textHtmlHandler = func;
};

/**
* Creates temporary attributes on a feature in order for featureinfo to display attributes from related tables and
* display attachments as links. Recursively adds attributes to related features in order to support multi level relations.
Expand Down Expand Up @@ -605,9 +610,15 @@ const Featureinfo = function Featureinfo(options = {}) {
* @param {any} featureObj An object containing layerName and feature. "feature" is either one Feature or an Array of Feature
* @param {any} opts An object containing options. Supported options are : coordinate, the coordinate where popup will be shown. If omitted first feature is used.
* ignorePan, do not autopan if type is overlay. Pan should be supressed if view is changed manually to avoid contradicting animations.
* maxZoomLevel, max level for zooming on feature.
* @returns nothing
*/
const showFeatureInfo = function showFeatureInfo(featureObj, opts = { ignorePan: true }) {
const showFeatureInfo = function showFeatureInfo(featureObj, opts) {
const thisOpts = { ...{
ignorePan: true
},
...opts };

const newItems = [];
const layerName = featureObj.layerName;
const layer = viewer.getLayer(layerName);
Expand All @@ -623,8 +634,8 @@ const Featureinfo = function Featureinfo(options = {}) {
newItems.push(newItem);
}
if (newItems.length > 0) {
render(newItems, identifyTarget, opts.coordinate || maputils.getCenter(newItems[0].getFeature().getGeometry()), opts);
viewer.getMap().getView().fit(maputils.getExtent(newItems.map(i => i.getFeature())));
render(newItems, identifyTarget, thisOpts.coordinate || maputils.getCenter(newItems[0].getFeature().getGeometry()), thisOpts);
viewer.getMap().getView().fit(maputils.getExtent(newItems.map(i => i.getFeature())), { maxZoom: thisOpts.maxZoomLevel });
}
};

Expand All @@ -647,7 +658,7 @@ const Featureinfo = function Featureinfo(options = {}) {
coordinate,
map,
pixel
}, viewer)
}, viewer, textHtmlHandler)
.then((data) => {
const serverResult = data || [];
const result = serverResult.concat(clientResult);
Expand Down Expand Up @@ -690,6 +701,7 @@ const Featureinfo = function Featureinfo(options = {}) {
getSelectionLayer,
getSelection,
addAttributeType,
addTextHtmlHandler,
onAdd(e) {
// Keep a reference to "ourselves"
component = this;
Expand Down
Loading

0 comments on commit 8af3134

Please sign in to comment.