Skip to content

Commit

Permalink
Filter out triangular rings with height (opposite longest base) less …
Browse files Browse the repository at this point in the history
…than 1 (#5731).
  • Loading branch information
sdlime committed Jan 21, 2019
1 parent 09632a6 commit 11e0565
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions mapmvt.c
Expand Up @@ -57,6 +57,21 @@ typedef struct {
#define COMMAND(id, count) (((id) & 0x7) | ((count) << 3))
#define PARAMETER(n) (((n) << 1) ^ ((n) >> 31))

static double getTriangleHeight(lineObj *ring)
{
int i;
double s=0, b=0;

if(ring->numpoints != 4) return -1; /* not a triangle */

for(i=0; i<ring->numpoints-1; i++) {
s += (ring->point[i].x*ring->point[i+1].y - ring->point[i+1].x*ring->point[i].y);
b = MS_MAX(b, msDistancePointToPoint(&ring->point[i], &ring->point[i+1]));
}

return (s/b);
}

static enum MS_RING_DIRECTION mvtGetRingDirection(lineObj *ring) {
int i, sum=0;

Expand Down Expand Up @@ -132,6 +147,11 @@ static int mvtTransformShape(shapeObj *shape, rectObj *extent, int layer_type, i
shape->line[i].numpoints = outj;

if(layer_type == MS_LAYER_POLYGON) {
if(shape->line[i].numpoints == 4 && getTriangleHeight(&shape->line[i]) < 1) {
shape->line[i].numpoints = 0; /* so it's not considered anymore */
continue; /* next ring */
}

ring_direction = mvtGetRingDirection(&shape->line[i]);
if(ring_direction == MS_DIRECTION_INVALID_RING)
shape->line[i].numpoints = 0; /* so it's not considered anymore */
Expand Down

0 comments on commit 11e0565

Please sign in to comment.