Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/1.1.x #135

Merged
merged 6 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "opengis",
"homepage": "https://opengis.simcoe.ca/public/",
"version": "1.2.0",
"version": "1.1.1",
"private": true,
"dependencies": {
"array-move": "^2.2.2",
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/drawingHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function getFeatureById(id) {
.getSource()
.getFeatures()
.forEach((feat) => {
if (feat.getProperties().id === id) feature = feat;
if (feat.get("id") === id) feature = feat;
return;
});
}
Expand Down
6 changes: 6 additions & 0 deletions src/map/Identify.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,9 @@
font-size: 9pt;
color: dimgray;
}

.sc-identify-add-my-map {
font-size: 9pt;
color: dimgray;
padding-left: 65%;
}
65 changes: 45 additions & 20 deletions src/map/Identify.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Circle as CircleStyle, Fill, Stroke, Style } from "ol/style.js";
import useIframeContentHeight from "react-use-iframe-content-height";
import Geometry from "ol/geom/Geometry";
import { useEffect } from "react";
import GeometryType from "ol/geom/GeometryType";

class Identify extends Component {
constructor(props) {
Expand Down Expand Up @@ -86,29 +87,43 @@ class Identify extends Component {
const extent = window.map.getView().calculateExtent();
wfsUrl = wfsUrl.replace("#GEOMETRY#", geometry.flatCoordinates).replace("#TOLERANCE#", 3).replace("#EXTENT#", extent.join(",")).replace("#RESOLUTION#", arcgisResolution);
} else {
wfsUrl += "INTERSECTS(geom," + wktString + ")";
if (geometry.getType() === "MultiPolygon") {
let intersectQuery = [];
geometry.getPolygons().forEach((poly) => {
const tmpFeature = new Feature(poly);
const tmpWKTString = helpers.getWKTStringFromFeature(tmpFeature);
intersectQuery.push("INTERSECTS(geom," + tmpWKTString + ")");
});
wfsUrl += intersectQuery.join(" OR ");
} else {
wfsUrl += "INTERSECTS(geom," + wktString + ")";
}
}
// QUERY USING WFS
// eslint-disable-next-line
helpers.getJSON(wfsUrl, (result) => {
const featureList = isArcGISLayer ? LayerHelpers.parseESRIIdentify(result) : new GeoJSON().readFeatures(result);
if (featureList.length > 0) {
if (displayName === "" || displayName === undefined) displayName = this.getDisplayNameFromFeature(featureList[0]);
let features = [];
featureList.forEach((feature) => {
features.push(feature);
});
if (features.length > 0)
layerList.push({
name: name,
features: features,
displayName: displayName,
type: type,
minScale: minScale,
if (wfsUrl.length > 8000) {
helpers.showMessage("Geometry too complex", "The geometry you are trying to use is too complex to identify.", helpers.messageColors.red);
} else {
helpers.getJSON(wfsUrl, (result) => {
const featureList = isArcGISLayer ? LayerHelpers.parseESRIIdentify(result) : new GeoJSON().readFeatures(result);
if (featureList.length > 0) {
if (displayName === "" || displayName === undefined) displayName = this.getDisplayNameFromFeature(featureList[0]);
let features = [];
featureList.forEach((feature) => {
features.push(feature);
});
this.setState({ layers: layerList });
}
});
if (features.length > 0)
layerList.push({
name: name,
features: features,
displayName: displayName,
type: type,
minScale: minScale,
});
this.setState({ layers: layerList });
}
});
}
} else {
let infoFormat = layer.get("INFO_FORMAT");
//console.log(infoFormat);
Expand Down Expand Up @@ -409,6 +424,10 @@ const FeatureItem = (props) => {
const [open, setOpen] = useState(false);
const [excludeIdentifyTitleName, setExcludeIdentifyTitleName] = useState(false);
let { feature, displayName, html_url, identifyTitleColumn, identifyIdColumn } = props;

const onMyMapsClick = (feature, featureName) => {
window.emitter.emit("addMyMapsFeature", feature, featureName);
};
useEffect(() => {
helpers.waitForLoad("settings", Date.now(), 30, () => setExcludeIdentifyTitleName(window.config.excludeIdentifyTitleName));
}, []);
Expand Down Expand Up @@ -470,8 +489,14 @@ const FeatureItem = (props) => {
) : (
""
)}
<div className={"sc-identify-add-my-map"}>
[&nbsp;
<span className="sc-fakeLink " onClick={() => onMyMapsClick(feature, featureName)}>
Add to My Maps
</span>
&nbsp;]
</div>
</div>

<div className={open ? "sc-identify-feature-content" : "sc-hidden"}>
<IFrame key={helpers.getUID()} src={html_url} filter={cql_filter} />
{cql_filter === "" ? helpers.FeatureContent({ feature: feature }) : ""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ export const CoordinateActions = (props) => {
<div className="sc-coordinates-row">
<label>&nbsp;</label>[{" "}
<span className="sc-fakeLink" onClick={props.onZoomClick}>
zoom
Zoom
</span>{" "}
] [{" "}
<span className="sc-fakeLink" onClick={props.onMyMapsClick}>
add to my Maps
Add to My Maps
</span>{" "}
]
</div>
Expand Down
21 changes: 17 additions & 4 deletions src/sidebar/components/tools/settings/Settings.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from "react";
import "./Settings.css";
import { ClearLocalStorageButton } from "./SettingsComponents.jsx";
import { ClearLocalStorageButton, ClearLocalStorageButtonGrouped } from "./SettingsComponents.jsx";
import * as helpers from "../../../../helpers/helpers";
import PanelComponent from "../../../PanelComponent";
import settingsConfig from "./config.json";
Expand Down Expand Up @@ -270,9 +270,22 @@ class Settings extends Component {
</button>
</div>
<div className="sc-settings-divider" />
{Object.keys(localStorage).map((key) => (
<ClearLocalStorageButton key={helpers.getUID()} storageKey={key} clearLocalData={this.clearLocalData} />
))}
{Object.keys(localStorage)
.filter((key) => {
return key.indexOf("login.microsoftonline.com") === -1;
})
.map((key) => (
<ClearLocalStorageButton key={helpers.getUID()} storageKey={key} clearLocalData={this.clearLocalData} />
))}

<ClearLocalStorageButtonGrouped
key={helpers.getUID()}
name={"Login Info"}
storageKeys={Object.keys(localStorage).filter((key) => {
return key.indexOf("login.microsoftonline.com") !== -1;
})}
clearLocalData={this.clearLocalData}
/>
</div>

<div className="sc-container sc-settings-floatbottom" />
Expand Down
22 changes: 22 additions & 0 deletions src/sidebar/components/tools/settings/SettingsComponents.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
import React from "react";

export const ClearLocalStorageButtonGrouped = (props) => {
if (!props.storageKeys || props.storageKeys.length === 0) return <div />;
return (
<div className="sc-settings-row sc-arrow">
<button
name={"clear-" + props.name}
title={"Clear items for " + props.name}
className="sc-button"
onClick={() => {
props.storageKeys.forEach((storageKey) => {
props.clearLocalData(storageKey);
});
}}
style={{ maxWidth: "315px" }}
>
{"Clear items in " + props.name}
</button>
<div className="sc-settings-divider" />
</div>
);
};

export const ClearLocalStorageButton = (props) => {
if (props.storageKey === undefined) return <div />;
return (
Expand Down