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

Prevent errors for missing DescribeFeatureType #2074

Merged
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 web/client/components/data/featuregrid/FeatureGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class FeatureGrid extends React.PureComponent {
this.props.changes[id].hasOwnProperty(key);
},
isProperty: (k) => k === "geometry" || isProperty(k, this.props.describeFeatureType),
isValid: (val, key) => isValidValueForPropertyName(val, key, this.props.describeFeatureType)
isValid: (val, key) => this.props.describeFeatureType ? isValidValueForPropertyName(val, key, this.props.describeFeatureType) : true
};
}
render() {
Expand Down
9 changes: 8 additions & 1 deletion web/client/epics/featuregrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
const Rx = require('rxjs');
const {get, head, isEmpty} = require('lodash');
const {get, head, isEmpty, find} = require('lodash');
const { LOCATION_CHANGE } = require('react-router-redux');
const axios = require('../libs/ajax');
const {fidFilter} = require('../utils/ogc/Filter/filter');
Expand Down Expand Up @@ -69,6 +69,13 @@ const setupDrawSupport = (state, original) => {
if (changes[feature.id] && (changes[feature.id].geometry || changes[feature.id].geometry === null)) {
feature.geometry = changes[feature.id].geometry;
}
if (feature._new && !feature.geometry) {
const stateNewFeature = find(newFeaturesSelector(state), {id: feature.id});
if (stateNewFeature && stateNewFeature.geometry ) {
feature.geometry = stateNewFeature.geometry;
}

}
if (original) {
feature.geometry = getFeatureById(state, feature.id) ? getFeatureById(state, feature.id).geometry : null;
}
Expand Down
1 change: 0 additions & 1 deletion web/client/examples/featuregrid/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/0.2.4/leaflet.draw.css" />
<link rel="stylesheet" href="../../dist/themes/default.css" id="theme_stylesheet">
<link rel="stylesheet" href="assets/css/viewer.css" id="theme_stylesheet">
<link rel="shortcut icon" type="image/png" href="https://cdn.jslibs.mapstore2.geo-solutions.it/leaflet/favicon.ico" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.10/proj4.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.js"></script>
Expand Down
4 changes: 3 additions & 1 deletion web/client/utils/FeatureGridUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const get = require('lodash');

const {getFeatureTypeProperties, isGeometryType, isValid, isValidValueForPropertyName, findGeometryProperty, getPropertyDesciptor} = require('./ogc/WFS/base');
const getGeometryName = (describe) => findGeometryProperty(describe).name;
const getGeometryName = (describe) => get(findGeometryProperty(describe), "name");
const getPropertyName = (name, describe) => name === "geometry" ? getGeometryName(describe) : name;

const getRow = (i, rows) => rows[i];
Expand Down
8 changes: 6 additions & 2 deletions web/client/utils/ogc/WFS/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const findGeometryProperty = (describeFeatureType) => head((getFeatureTypeProper
*/
const getPropertyDesciptor = (propName, describeFeatureType) =>
head(
getFeatureTypeProperties(describeFeatureType).filter(d => d.name === propName)
(getFeatureTypeProperties(describeFeatureType) || []).filter(d => d.name === propName)
);
/**
* @name schemaLocation
Expand All @@ -57,7 +57,11 @@ const getPropertyDesciptor = (propName, describeFeatureType) =>
*/
const schemaLocation = (d) => d.targetNamespace;
const isGeometryType = (pd) => pd.type.indexOf("gml:") === 0;
const isValidValue = (v, pd) => pd.nillable || (v !== undefined && v !== null); // TODO validate type
const isValidValue = (v, pd) =>
pd === undefined
|| pd === null
|| pd && pd.nillable === true
|| pd && pd.nillable === false && v !== undefined && v !== null; // TODO validate type
const isValidProperty = ({geom, properties} = {}, pd) => isValidValue(isGeometryType(pd) ? geom : properties[pd.name], pd);
/**
* Base utilities for WFS.
Expand Down