java - JTS/Geotools Correct union/difference of multiple geometry -


problem :

i have shape file contains targeted area (yellow).

i have shape file contains buildings (green).

i need white space in yellow area.

picture : ://db.tt/kjjxzlqf

my solutions :

  1. get buildings in area

    filter inpolygon = cql.tofilter("within(the_geom,"+wktwriter.write(targetarea) + ")");

    featurecollection<simplefeaturetype, simplefeature> collection = featuresource.getfeatures(inpolygon);//this works

  2. from every building it's geometry , use difference on target area

    tocover = tocover.difference(building);

or second solution :

union of every building , difference @ end.

or third solution :

put them in geomtrycollection call union , use difference

everyone of these solutions give me following picture

picture : https://dl.dropboxusercontent.com/u/639458/stackoverflow/stfr2.png

let clear tried out several ways solve problem, using different ways of creating / making or using it. given code in site below did not work correct.

http://docs.geotools.org/latest/userguide/library/jts/combine.html

my problems solved in end @mdup had suggested use of

.buffer(0) 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -