Skip to content

Commit

Permalink
Prevent errors for missing DescribeFeatureType (#2074)
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz authored Aug 2, 2017
1 parent f78a226 commit dfa6989
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
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
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

0 comments on commit dfa6989

Please sign in to comment.