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

Added 2 failing feature tests around empty GeoJSON data structures #912

Closed
wants to merge 1 commit into from
Closed
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
29 changes: 29 additions & 0 deletions test/feature.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,35 @@ describe('mapnik.Feature ', function() {
assert.deepEqual(expected, f.geometry().toWKB());
assert.deepEqual(expected, f.toWKB());
});

it('should round trip an empty geojson', function() {
var input = {};
var ds = new mapnik.Datasource({ type:'geojson', inline: JSON.stringify(input) });
var fs = ds.featureset()
var feat = fs.next();
var feature = JSON.parse(feat.toJSON());
assert.equal(input.type, feature.type);
assert.deepEqual(input.geometry, feature.geometry);
// expected that the array is stringified after https://github.com/mapnik/mapnik/issues/2678
input.properties.something = "[]";
assert.deepEqual(input.properties, feature.properties);
});

it('should round trip an empty geojson', function() {
var input = {
"type": "FeatureCollection",
"features": []
};
var ds = new mapnik.Datasource({ type:'geojson', inline: JSON.stringify(input) });
var fs = ds.featureset()
var feat = fs.next();
var feature = JSON.parse(feat.toJSON());
assert.equal(input.type, feature.type);
assert.deepEqual(input.geometry, feature.geometry);
// expected that the array is stringified after https://github.com/mapnik/mapnik/issues/2678
input.properties.something = "[]";
assert.deepEqual(input.properties, feature.properties);
});

it('should round trip a geojson property with an array', function() {
var input = {
Expand Down