Skip to content

Commit

Permalink
Support multipoint geometries in shapefiles (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
systemed authored Jan 14, 2024
1 parent 3ff08a3 commit 3f05682
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/shp_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,23 @@ void ShpProcessor::processShapeGeometry(SHPObject* shape, AttributeIndex attrIdx
int shapeType = shape->nSHPType; // 1=point, 3=polyline, 5=(multi)polygon [8=multipoint, 11+=3D]
int minzoom = layer.minzoom;

if (shapeType==1) {
if (shapeType==1 || shapeType==11 || shapeType==21) {
// Points
Point p( shape->padfX[0], lat2latp(shape->padfY[0]) );
if (geom::within(p, clippingBox)) {
shpMemTiles.StoreGeometry(layerNum, layer.name, POINT_, p, layer.indexed, hasName, name, minzoom, attrIdx);
}

} else if (shapeType==3) {
} else if (shapeType==8 || shapeType==18 || shapeType==28) {
// Multipoint
for (uint i=0; i<shape->nVertices; i++) {
Point p( shape->padfX[i], lat2latp(shape->padfY[i]) );
if (geom::within(p, clippingBox)) {
shpMemTiles.StoreGeometry(layerNum, layer.name, POINT_, p, layer.indexed, hasName, name, minzoom, attrIdx);
}
}

} else if (shapeType==3 || shapeType==13 || shapeType==23) {
// (Multi)-polylines
// Due to https://svn.boost.org/trac/boost/ticket/11268, we can't clip a MultiLinestring with Boost 1.56-1.58,
// so we need to create everything as polylines and clip individually :(
Expand All @@ -197,7 +206,7 @@ void ShpProcessor::processShapeGeometry(SHPObject* shape, AttributeIndex attrIdx
}
}

} else if (shapeType==5) {
} else if (shapeType==5 || shapeType==15 || shapeType==25) {
// (Multi)-polygons
MultiPolygon multi;
Polygon poly;
Expand Down

0 comments on commit 3f05682

Please sign in to comment.