Created
May 4, 2017 18:55
-
-
Save chadwilcomb/03c332864a0d4fdf85190d738eb59f5e to your computer and use it in GitHub Desktop.
Script to run through a Mongo collection with some malformed geometries and flag and unset the geometries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (i = 0; i < 139; i++) { | |
db.basemap_clean.ensureIndex({ geometry: "2dsphere" }) | |
db.basemap_features | |
.find({ clean: { $exists: 0 } }, { "geometry": 1 }) | |
.limit(500000) | |
.forEach(function (feature) { | |
db.basemap_clean.insert(feature); | |
}); | |
db.basemap_clean | |
.find() | |
.forEach(function (clean) { | |
db.basemap_features.update({ _id: clean._id }, { $set: { clean: 1 } }) | |
}); | |
db.basemap_clean.drop(); | |
} | |
db.basemap_features.find({ clean: { $exists: 0 }}).forEach(function (doc) { | |
db.basemap_features.update( | |
{ _id: doc._id }, | |
{ $set: { malgeo: doc.geometry }, $unset: { geometry: 1 } } | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment