Skip to content

Strange behavior #15

Description

@romka-chev

Hello!

I ran into a rather strange behavior of the library. I think that all of the examples will be clear.

In both examples, the left side on the map can be set for the geometry subjectPolygon and clipPolygon (they can push and edit). On the map to the right shows the output for this example. The resulting polygons can pull apart to see in detail what happened.

Yellow polygon is a "clipPolygon"
Blue polygons is a "subjectPolygons"

Actually, the strange behavior is the first example - there is no right "and" polygon.

A second example, despite the fact that the geometry is really mad, everything works as it should.

What is the problem? Maybe I'm somewhere makes a mistake?

First (wierd) example - http://jsfiddle.net/romkachev/jjaaxnng/
Second (normal) example - http://jsfiddle.net/romkachev/c2o8816a/

P.S. Here is the listing of code on nodejs which process requests:

var express = require('express');
var polygonBoolean = require('2d-polygon-boolean');
var _ = require('lodash');
var router = express.Router();

router.get('/polygons-boolean', function (req, res) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "X-Requested-With");

    var subjectPolygons = req.query['subjectPolygons'];
    var clipPolygon = req.query['clipPolygon'];
    var mode = req.query['mode'];

    var result = [];

    _.each(subjectPolygons, function (subjectPolygon) {
        var innerResult = [];
        // in case of polygons don't even intersects
        try {
            innerResult = polygonBoolean(subjectPolygon, clipPolygon, mode);
        } catch (e) {
        }

        if (innerResult.length) {
            _.each(innerResult, function (polygon) {
                result.push(polygon);
            })
        }
    });

    res.type('application/json');
    res.send(result);
});

module.exports = router;

PPS - sorry for my engrish.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions