[OpenLayers-Users] CascadedPolygonUnion using JSTS in OpenLayers

rickm81 rickm81 at yahoo.com
Wed Jun 18 07:50:35 PDT 2014


Hello,

I'm using the JavaScript Topology Suite to union polygons in OpenLayers.
Everything works fine if I iterate through polygons in vector layer.
However, I believe I could improve performance with the CascadedPolygonUnion
function. 

Is there an example of CascadePolygonUnion using geometries parsed from
OpenLayers? Below is an example of the method I am currently using. Thank
you!

var vLayer = new OpenLayers.Layer.Vector("Polygons", { styleMap: new
OpenLayers.StyleMap({ fillOpacity: 0.4, fillColor: "#FF0000", strokeColor:
"#FF0000"}) });
var mLayer = new OpenLayers.Layer.Vector("Merged Polygons", { styleMap: new
OpenLayers.StyleMap({ fillOpacity: 0.4, fillColor:  "#FF0000", strokeColor: 
"#FF0000"}) });

var jsts_parser = new jsts.io.OpenLayersParser();
var fts = vLayer.features;
    for (var q = 0; q < fts.length; q++) {
        if (q == 0) {
            var jsts_geomA = jsts_parser.read(fts[q].geometry);
        }
        else {
            var jsts_geomB = jsts_parser.read(fts[q].geometry);

            jsts_result_geom = jsts_geomA.union(jsts_geomB);

        }
    }
    var ol_geom = jsts_parser.write(jsts_result_geom);
    var ol_ft = new OpenLayers.Feature.Vector(ol_geom);
    mLayer.addFeatures(ol_ft);




--
View this message in context: http://osgeo-org.1560.x6.nabble.com/CascadedPolygonUnion-using-JSTS-in-OpenLayers-tp5146545.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list