I want to square building surfaces which are almost rectangular. I didn't find any tool in an OSgis. But there is a java library opencarto which includes such an algorithm. I'm not a professional java developer, but as i can see in the code below there are two getter methods which wait for a polygon input. My Question is how can I select with a Filechooser in java the shapefile and make every single polygon of this shapefile running through this algorithm? Or exists there almost a tool which can handle this?

public class Squarring {

public static Polygon get(Polygon poly) {
    return get(poly, 20, -1, 0.01);

public static Polygon get(Polygon poly, double angleToleranceDeg, int pointActivationLimitNb, double res) {
    Polygon poly2 = (Polygon) poly.clone();
    HashSet<GPoint> ps = new HashSet<GPoint>();
    HashSet<GSegment> segs = new HashSet<GSegment>();
    Decomposers.decomposeLimit(poly2, res, ps, segs, false, null);

    double o=new Orientation(poly2).getSidesOrientation();

    for (GSegment s : segs)..........
  • Welcome to GIS SE! As a new user please take the tour to learn about our focused Question and Answer format. Please edit your question to include your code snippet as text pasted into the question rather than as an image. Text is easier to read, can be copy/pasted by potential answerers to test, and is also makes it searchable for users with the same or similar problems. – Midavalo Oct 25 '16 at 18:10

Your Answer

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

Browse other questions tagged or ask your own question.