Closed morganherlocker closed 10 years ago
This is being changed to "simplify", since that is what douglas peucker really does. mapshaper will be used for this.
stubbed out, but need to figure out how to properly use topojson from node.
You need to figure out quantization and simplification, if you have them as q
and s
with geojson geojson
function(q,s,geojson){
var options = {
"quantization" : q,
"minimum-area" : s,
"property-transform": function (properties, key, value) {
//keeps all
properties[key] = value;
return true;
}
}
var topo =topojson.topology({name:geojson}, options);
topojson.simplify(topo,options);
return topojson.feature(topo, topo.objects.name);
}
Perfect, that is great. I will implement this in the next couple days.
Thanks!
This feature has been implemented. I will add an example to the docs shortly.
Hi Morgan,
It great to be able to do this on Polygons. I would very much like the ability to apply simplification on LineString. While at it - it would also be nice to be able to apply simplification on a single polygon or LineString.
Cheers, Lars
might look into simplify-js for stuff where topojson is overkill
Hey Lars,
It will currently work on a feature collection of polygons. I think it will work on a feature collection of linestrings too. I will write a test for the lines. As far as the single features go, I think that is a great idea and will be simple to add in. I will reopen this issue until I have both of these things resolved.
topojson (and the snippit I wrote) should work fine for any sort of feature collection of any of the 7 types in any combination (obviously points don't get simplified)
On Thu, Dec 5, 2013 at 8:44 AM, Morgan Herlocker notifications@github.comwrote:
Hey Lars,
It will currently work on a feature collection of polygons. I think it will work on a feature collection of linestrings too. I will write a test for the lines. As far as the single features go, I think that is a great idea and will be simple to add in. I will reopen this issue until I have both of these things resolved.
— Reply to this email directly or view it on GitHubhttps://github.com/morganherlocker/turf/issues/17#issuecomment-29898149 .
-Calvin W. Metcalf
@calvinmetcalf @LarsBuur I added tests for for the various feature types and everything is passing https://github.com/morganherlocker/turf/blob/master/test/simplify.js
Great! - thank you very much. I will look into the simplification and report back.
Takes a collection of detailed polygons and smooths out the edges to a given tolerance. It will probably use a Ramer Douglas Peucker algorithm or something similar. This will probably require the use of topojson to maintain edge integrity of geographies.