Open gonponlotus opened 4 years ago
geomentry := (metaData.Shape).(*goShp.Polygon)
coords := [][]geom.Coord{}
for i := int32(0); i < geomentry.NumParts; i++ {
coord := []geom.Coord{}
if i == 0 {
if geomentry.NumParts > 1 {
for _, point := range geomentry.Points[0:geomentry.Parts[i+1]] {
coord = append(coord, []float64{point.X, point.Y})
}
coords = append(coords, coord)
} else { // 只有一个部分
for _, point := range geomentry.Points[0:] {
coord = append(coord, []float64{point.X, point.Y})
}
coords = append(coords, coord)
}
} else if i == geomentry.NumParts-1 {
for _, point := range geomentry.Points[geomentry.Parts[i]:] {
coord = append(coord, []float64{point.X, point.Y})
}
coords = append(coords, coord)
} else {
for _, point := range geomentry.Points[geomentry.Parts[i]:geomentry.Parts[i+1]] {
coord = append(coord, []float64{point.X, point.Y})
}
coords = append(coords, coord)
}
}
polygon := geom.NewPolygon(geom.XY).MustSetCoords(coords).SetSRID(4326)
Hi everyone, how can i read shapefile with the geom is multipolygon and convert to array list polygon
thank you