Skip to content

Commit

Permalink
[kmeanscluster] implemented support for multipolygons
Browse files Browse the repository at this point in the history
  • Loading branch information
biodiv committed Jul 24, 2014
1 parent c5341d3 commit 462f00b
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions anycluster/MapClusterer.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,32 @@ def getClusterGeometries(self, request, params, clustertype):

elif clusterGeometries_geojson["type"] == "Feature":

geos = self.convertGeojsonFeatureToGEOS(clusterGeometries_geojson)
if clusterGeometries_geojson["geometry"]["type"] == "MultiPolygon":

if geos:
k = self.calculateK(geos)

clusterGeometries = [{"geos": geos, "k":k}]

properties = clusterGeometries_geojson.get("properties", {})

for polygon in clusterGeometries_geojson["geometry"]["coordinates"][0]:

geom = {"type": "Feature", "geometry": { "type": "Polygon", "coordinates": [polygon] }, "properties": properties }

geos = self.convertGeojsonFeatureToGEOS(geom)

if geos:

k = self.calculateK(geos)

clusterGeometries.append({"geos": geos, "k":k})

else:

geos = self.convertGeojsonFeatureToGEOS(clusterGeometries_geojson)

if geos:

k = self.calculateK(geos)

clusterGeometries = [{"geos": geos, "k":k}]


return clusterGeometries
Expand Down

0 comments on commit 462f00b

Please sign in to comment.