void OpenGLHelper::getLineVertices(const ICoordinateSystem& csyRoot, const ICoordinateSystem& csyGeom, const Ilwis::UPGeometry &geometry, Raw objectid, QVector<QVector3D> &points, QVector<QVector3D> &normals, std::vector<VertexIndex> &indices){ int n = geometry->getNumGeometries(); for(int geom = 0; geom < n; ++geom ){ const geos::geom::Geometry *subgeom = geometry->getGeometryN(geom); if (!subgeom) continue; auto *coords = subgeom->getCoordinates(); quint32 oldend = points.size(); indices.push_back(VertexIndex(oldend, coords->size(), GL_LINE_STRIP, objectid)); points.resize(oldend + coords->size()); bool conversionNeeded = csyRoot != csyGeom; Coordinate crd; for(int i = 0; i < coords->size(); ++i){ coords->getAt(i, crd); if ( conversionNeeded){ crd = csyRoot->coord2coord(csyGeom, crd); } points[oldend + i] = QVector3D(crd.x, crd.y, crd.z); } delete coords; } }
std::vector<std::vector<float> > IlwisTesselator::getContours(const geos::geom::Geometry *geometry,const ICoordinateSystem &csyRoot, const ICoordinateSystem &csyGeom) { bool conversionNeeded = csyRoot != csyGeom; const geos::geom::Polygon *polygon = dynamic_cast<const geos::geom::Polygon *>(geometry); if (polygon){ const geos::geom::LineString *outerRing = polygon->getExteriorRing(); std::vector<std::vector<float>> contours(1); contours[0].resize(outerRing->getNumPoints() * 2); auto addCoord = [&](const geos::geom::Coordinate& crd, int index, int i) { if ( conversionNeeded){ Coordinate crdTransformed = csyRoot->coord2coord(csyGeom,crd); contours[index][i] = crdTransformed.x; contours[index][i+1] = crdTransformed.y; } else{ contours[index][i] = crd.x; contours[index][i+1] = crd.y; } }; for(int i = 0 ; i < outerRing->getNumPoints(); ++i){ const geos::geom::Coordinate& crd = outerRing->getCoordinateN(i); addCoord(crd, 0, i * 2); } if ( polygon->getNumInteriorRing() > 0){ contours.resize(polygon->getNumInteriorRing() + 1); for(int i = 0; i < polygon->getNumInteriorRing(); ++i){ const geos::geom::LineString *innerRing = polygon->getInteriorRingN(i); contours[i + 1].resize(innerRing->getNumPoints() * 2); // contours[0] is outer ring for(int j = 0 ; j < innerRing->getNumPoints(); ++j){ const geos::geom::Coordinate& crd = innerRing->getCoordinateN(j); addCoord(crd, i+1, j * 2); } } } return contours; } return std::vector<std::vector<float>>(); }
void OpenGLHelper::getPointVertices(const ICoordinateSystem& csyRoot, const ICoordinateSystem& csyGeom, const Ilwis::UPGeometry &geometry, Raw objectid, QVector<QVector3D> &points, QVector<QVector3D> &normals, std::vector<VertexIndex> &indices){ int n = geometry->getNumGeometries(); for(int geom = 0; geom < n; ++geom ){ const geos::geom::Geometry *subgeom = geometry->getGeometryN(geom); if (!subgeom) continue; const geos::geom::Coordinate *crd = subgeom->getCoordinate(); indices.push_back(VertexIndex(points.size(),1,GL_POINTS,objectid)); bool conversionNeeded = csyRoot != csyGeom; Coordinate coord = *crd; if ( conversionNeeded){ coord = csyRoot->coord2coord(csyGeom, *crd); } points.push_back(QVector3D(coord.x, coord.y, coord.z)); } }