1

I am working on a tool for my map but I’m running into some problems using gs:Clip. The user draws a line. All the polygons from a certain layer that intersects the drawn feature have an attribute that is supposed to be calculated (the total sum is wanted). So, for instance, the user might draw a line that crosses two polygons with attribute values of 2 and 4, thus the code should return 6.

It works by saving the user drawn line in an OpenLayers vector layer. The feature drawn is then used (in WKT format) in a chained WPS request. A gs:Clip request (WKT used for clipping) is used as the input for a gs:Aggregate request. Complete code for the WPS request can be found here. The problem is that polygons that do not intersect the drawn line but are close to it are also part of the calculation. See the picture below, it might illustrate the problem somewhat better.

Picture illustrating the problem

Below is part of the code from the response of gs:Clip (an unwanted feature). No boundedBy coordinates nor any coordinates after the feature:the_geom tag. All the features that should be clipped (corresponding to the drawn lines in the picture above) contains coordinates, but for some reason features that are not within the clipping area gets added to the wfs-FeatureCollection and are consequently part of the gs:Aggregate calculation, causing the end result to be incorrect.

//This is a feature that is unwanted in the response
<gml:featureMember>
<feature:IR_Y fid="IR_Y.1295">
     <gml:boundedBy>
        <gml:null>unknown</gml:null>
     </gml:boundedBy>
     <feature:the_geom>
        <gml:MultiPolygon srsName="http://www.opengis.net/gml/srs/epsg.xml#3010">
           <gml:polygonMember />
        </gml:MultiPolygon>
     </feature:the_geom>
     <feature:BT>5</feature:BT>
  </feature:IR_Y>
</gml:featureMember>
  • Not sure, but could it be that the process creates envelopes for the line features to calculate the intersection? – ylka Feb 28 '14 at 14:07
  • Sure, that's possible, I don't know how the processes actually work. Maybe using clip isn't the best option when working with attributes. – Markus Mar 3 '14 at 10:20
1

I trid using gs:IntersectionFeatureCollection instead of clip, and it works much better, so I think ylka was on to something regarding clip.

What happens now is that the user drawn feature is first converted to a featurecollection (wkt to featurecollection) using gs:Feature, then that is used as the 2nd input in the gs:IntersectionFeatureCollection process (gs:Feature and gs:IntersectionFeatureCollection are chained). I then get the result in json format and use it as input for the gs:Aggregate process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.