Skip to content

Commit

Permalink
dont crap out of fs response with no features
Browse files Browse the repository at this point in the history
  • Loading branch information
dmfenton committed Mar 29, 2016
1 parent 31ba3dd commit 105fb04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased
### Fixed
* Dont throw an exception when feature service response has no features

## [3.0.0-alpha.16] - 2016-03-15
### Changed
* Rebuild
Expand Down
4 changes: 2 additions & 2 deletions src/lib/FeatureServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function fields (props, idField, list) {
function processTemplate (tmpl, data, params) {
const template = templates[tmpl]

if (tmpl !== 'featureService') {
if (tmpl !== 'featureService' && data && data.features && data.features.length) {
const fieldObj = fields(data.features[0].properties, params.idField, (data.info) ? data.info.fields : null)
template.fields = fieldObj.fields
if (template.objectIdFieldName) template.objectIdFieldName = fieldObj.oidField
Expand Down Expand Up @@ -299,7 +299,7 @@ function queryData (data, params, callback) {
data.type = 'FeatureCollection'
}

if (data.features[0] && data.features[0].properties.OBJECTID) {
if (data.features && data.features[0] && data.features[0].properties.OBJECTID) {
json.features = terraformerParser.convert(data)
} else {
json.features = terraformerParser.convert(data, { idAttribute: 'id' })
Expand Down

0 comments on commit 105fb04

Please sign in to comment.