Skip to content

Commit 3f05682

Browse files
authored
Support multipoint geometries in shapefiles (#640)
1 parent 3ff08a3 commit 3f05682

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/shp_processor.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,23 @@ void ShpProcessor::processShapeGeometry(SHPObject* shape, AttributeIndex attrIdx
174174
int shapeType = shape->nSHPType; // 1=point, 3=polyline, 5=(multi)polygon [8=multipoint, 11+=3D]
175175
int minzoom = layer.minzoom;
176176

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

184-
} else if (shapeType==3) {
184+
} else if (shapeType==8 || shapeType==18 || shapeType==28) {
185+
// Multipoint
186+
for (uint i=0; i<shape->nVertices; i++) {
187+
Point p( shape->padfX[i], lat2latp(shape->padfY[i]) );
188+
if (geom::within(p, clippingBox)) {
189+
shpMemTiles.StoreGeometry(layerNum, layer.name, POINT_, p, layer.indexed, hasName, name, minzoom, attrIdx);
190+
}
191+
}
192+
193+
} else if (shapeType==3 || shapeType==13 || shapeType==23) {
185194
// (Multi)-polylines
186195
// Due to https://svn.boost.org/trac/boost/ticket/11268, we can't clip a MultiLinestring with Boost 1.56-1.58,
187196
// so we need to create everything as polylines and clip individually :(
@@ -197,7 +206,7 @@ void ShpProcessor::processShapeGeometry(SHPObject* shape, AttributeIndex attrIdx
197206
}
198207
}
199208

200-
} else if (shapeType==5) {
209+
} else if (shapeType==5 || shapeType==15 || shapeType==25) {
201210
// (Multi)-polygons
202211
MultiPolygon multi;
203212
Polygon poly;

0 commit comments

Comments
 (0)