/*! \brief Load geometry (linestring HP/DPM layer) \return number of invalid features */ int VFKDataBlock::LoadGeometryLineStringHP() { long nInvalid; int idxId, idxMy_Id, idxPCB; GUIntBig id; VFKDataBlock *poDataBlockLines; VFKFeature *poFeature, *poLine; VFKFeatureList poLineList; nInvalid = 0; poDataBlockLines = (VFKDataBlock *) m_poReader->GetDataBlock("SBP"); if (NULL == poDataBlockLines) { CPLError(CE_Failure, CPLE_NotSupported, "Data block %s not found.\n", m_pszName); return nInvalid; } poDataBlockLines->LoadGeometry(); idxId = GetPropertyIndex("ID"); if (EQUAL (m_pszName, "HP")) idxMy_Id = poDataBlockLines->GetPropertyIndex("HP_ID"); else idxMy_Id = poDataBlockLines->GetPropertyIndex("DPM_ID"); idxPCB = poDataBlockLines->GetPropertyIndex("PORADOVE_CISLO_BODU"); if (idxId < 0 || idxMy_Id < 0 || idxPCB < 0) { CPLError(CE_Failure, CPLE_NotSupported, "Corrupted data (%s).\n", m_pszName); return nInvalid; } poLineList = poDataBlockLines->GetFeatures(idxPCB, 1); /* reduce to first segment */ for (int i = 0; i < ((IVFKDataBlock *) this)->GetFeatureCount(); i++) { poFeature = (VFKFeature *) GetFeatureByIndex(i); id = strtoul(poFeature->GetProperty(idxId)->GetValueS(), NULL, 0); poLine = poDataBlockLines->GetFeature(idxMy_Id, id, &poLineList); if (!poLine || !poLine->GetGeometry()) continue; if (!poFeature->SetGeometry(poLine->GetGeometry())) nInvalid++; } poDataBlockLines->ResetReading(); return nInvalid; }
/*! \brief Load geometry (linestring SBP layer) \return number of invalid features */ int VFKDataBlock::LoadGeometryLineStringSBP() { int idxId, idxBp_Id, idxPCB; GUIntBig id, ipcb; int nInvalid; VFKDataBlock *poDataBlockPoints; VFKFeature *poFeature, *poPoint, *poLine; OGRLineString oOGRLine; nInvalid = 0; poLine = NULL; poDataBlockPoints = (VFKDataBlock *) m_poReader->GetDataBlock("SOBR"); if (NULL == poDataBlockPoints) { CPLError(CE_Failure, CPLE_NotSupported, "Data block %s not found.\n", m_pszName); return nInvalid; } poDataBlockPoints->LoadGeometry(); idxId = poDataBlockPoints->GetPropertyIndex("ID"); idxBp_Id = GetPropertyIndex("BP_ID"); idxPCB = GetPropertyIndex("PORADOVE_CISLO_BODU"); if (idxId < 0 || idxBp_Id < 0 || idxPCB < 0) { CPLError(CE_Failure, CPLE_NotSupported, "Corrupted data (%s).\n", m_pszName); return nInvalid; } for (int j = 0; j < ((IVFKDataBlock *) this)->GetFeatureCount(); j++) { poFeature = (VFKFeature *) GetFeatureByIndex(j); poFeature->SetGeometry(NULL); id = strtoul(poFeature->GetProperty(idxBp_Id)->GetValueS(), NULL, 0); ipcb = strtoul(poFeature->GetProperty(idxPCB)->GetValueS(), NULL, 0); if (ipcb == 1) { if (!oOGRLine.IsEmpty()) { oOGRLine.setCoordinateDimension(2); /* force 2D */ if (!poLine->SetGeometry(&oOGRLine)) nInvalid++; oOGRLine.empty(); /* restore line */ } poLine = poFeature; } else { poFeature->SetGeometryType(wkbUnknown); } poPoint = poDataBlockPoints->GetFeature(idxId, id); if (!poPoint) continue; OGRPoint *pt = (OGRPoint *) poPoint->GetGeometry(); oOGRLine.addPoint(pt); } /* add last line */ oOGRLine.setCoordinateDimension(2); /* force 2D */ if (poLine) { if (!poLine->SetGeometry(&oOGRLine)) nInvalid++; } poDataBlockPoints->ResetReading(); return nInvalid; }