本文整理汇总了C++中OGRPoint::assignSpatialReference方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRPoint::assignSpatialReference方法的具体用法?C++ OGRPoint::assignSpatialReference怎么用?C++ OGRPoint::assignSpatialReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRPoint
的用法示例。
在下文中一共展示了OGRPoint::assignSpatialReference方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
OGRFeature *OGROpenAirLabelLayer::GetNextRawFeature()
{
const char* pszLine;
double dfLat = 0, dfLon = 0;
int bHasCoord = FALSE;
while(TRUE)
{
pszLine = CPLReadLine2L(fpOpenAir, 1024, NULL);
if (pszLine == NULL)
return NULL;
if (pszLine[0] == '*' || pszLine[0] == '\0')
continue;
if (EQUALN(pszLine, "AC ", 3))
{
if (osCLASS.size() != 0)
{
osNAME = "";
osCEILING = "";
osFLOOR = "";
}
osCLASS = pszLine + 3;
}
else if (EQUALN(pszLine, "AN ", 3))
osNAME = pszLine + 3;
else if (EQUALN(pszLine, "AH ", 3))
osCEILING = pszLine + 3;
else if (EQUALN(pszLine, "AL ", 3))
osFLOOR = pszLine + 3;
else if (EQUALN(pszLine, "AT ", 3))
{
bHasCoord = OGROpenAirGetLatLon(pszLine + 3, dfLat, dfLon);
break;
}
}
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
poFeature->SetField(0, osCLASS.c_str());
poFeature->SetField(1, osNAME.c_str());
poFeature->SetField(2, osFLOOR.c_str());
poFeature->SetField(3, osCEILING.c_str());
CPLString osStyle;
osStyle.Printf("LABEL(t:\"%s\")", osNAME.c_str());
poFeature->SetStyleString(osStyle.c_str());
if (bHasCoord)
{
OGRPoint* poPoint = new OGRPoint(dfLon, dfLat);
poPoint->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly(poPoint);
}
poFeature->SetFID(nNextFID++);
return poFeature;
}
示例2: OGRPoint
OGRGeometry *OGRPoint::clone() const
{
OGRPoint *poNewPoint = new OGRPoint( x, y, z );
poNewPoint->assignSpatialReference( getSpatialReference() );
return poNewPoint;
}
示例3: OGRPoint
OGRGeometry *OGRPoint::clone() const
{
OGRPoint *poNewPoint = new OGRPoint( x, y, z );
poNewPoint->assignSpatialReference( getSpatialReference() );
poNewPoint->setCoordinateDimension( nCoordDimension );
return poNewPoint;
}
示例4: new
OGRGeometry *OGRPoint::clone() const
{
OGRPoint *poNewPoint = new (std::nothrow) OGRPoint( x, y, z, m );
if( poNewPoint == NULL )
return NULL;
poNewPoint->assignSpatialReference( getSpatialReference() );
poNewPoint->flags = flags;
return poNewPoint;
}
示例5: if
OGRFeature *OGROGDILayer::GetNextRawFeature()
{
ecs_Result *psResult;
int i;
OGRFeature *poFeature;
/* -------------------------------------------------------------------- */
/* Retrieve object from OGDI server and create new feature */
/* -------------------------------------------------------------------- */
psResult = cln_GetNextObject(m_nClientID);
if (! ECSSUCCESS(psResult))
{
// We probably reached EOF... keep track of shape count.
m_nTotalShapeCount = m_iNextShapeId - m_nFilteredOutShapes;
return NULL;
}
poFeature = new OGRFeature(m_poFeatureDefn);
poFeature->SetFID( m_iNextShapeId++ );
m_nFeaturesRead++;
/* -------------------------------------------------------------------- */
/* Process geometry */
/* -------------------------------------------------------------------- */
if (m_eFamily == Point)
{
ecs_Point *psPoint = &(ECSGEOM(psResult).point);
OGRPoint *poOGRPoint = new OGRPoint(psPoint->c.x, psPoint->c.y);
poOGRPoint->assignSpatialReference(m_poSpatialRef);
poFeature->SetGeometryDirectly(poOGRPoint);
}
else if (m_eFamily == Line)
{
ecs_Line *psLine = &(ECSGEOM(psResult).line);
OGRLineString *poOGRLine = new OGRLineString();
poOGRLine->setNumPoints( psLine->c.c_len );
for( i=0; i < (int) psLine->c.c_len; i++ )
{
poOGRLine->setPoint(i, psLine->c.c_val[i].x, psLine->c.c_val[i].y);
}
poOGRLine->assignSpatialReference(m_poSpatialRef);
poFeature->SetGeometryDirectly(poOGRLine);
}
else if (m_eFamily == Area)
{
ecs_Area *psArea = &(ECSGEOM(psResult).area);
OGRPolygon *poOGRPolygon = new OGRPolygon();
for(int iRing=0; iRing < (int) psArea->ring.ring_len; iRing++)
{
ecs_FeatureRing *psRing = &(psArea->ring.ring_val[iRing]);
OGRLinearRing *poOGRRing = new OGRLinearRing();
poOGRRing->setNumPoints( psRing->c.c_len );
for( i=0; i < (int) psRing->c.c_len; i++ )
{
poOGRRing->setPoint(i, psRing->c.c_val[i].x,
psRing->c.c_val[i].y);
}
poOGRPolygon->addRingDirectly(poOGRRing);
}
// __TODO__
// When OGR supports polygon centroids then we should carry them here
poOGRPolygon->assignSpatialReference(m_poSpatialRef);
poFeature->SetGeometryDirectly(poOGRPolygon);
}
else if (m_eFamily == Text)
{
// __TODO__
// For now text is treated as a point and string is lost
//
ecs_Text *psText = &(ECSGEOM(psResult).text);
OGRPoint *poOGRPoint = new OGRPoint(psText->c.x, psText->c.y);
poOGRPoint->assignSpatialReference(m_poSpatialRef);
poFeature->SetGeometryDirectly(poOGRPoint);
}
else
{
CPLAssert(FALSE);
}
/* -------------------------------------------------------------------- */
/* Set attributes */
/* -------------------------------------------------------------------- */
char *pszAttrList = ECSOBJECTATTR(psResult);
for( int iField = 0; iField < m_poFeatureDefn->GetFieldCount(); iField++ )
{
char *pszFieldStart;
int nNameLen;
//.........这里部分代码省略.........
示例6: OGRPoint
OGRFeature *OGRPCIDSKLayer::GetFeature( GIntBig nFID )
{
/* -------------------------------------------------------------------- */
/* Create the OGR feature. */
/* -------------------------------------------------------------------- */
OGRFeature *poFeature;
poFeature = new OGRFeature( poFeatureDefn );
poFeature->SetFID( (int) nFID );
/* -------------------------------------------------------------------- */
/* Set attributes for any indicated attribute records. */
/* -------------------------------------------------------------------- */
try {
std::vector<PCIDSK::ShapeField> aoFields;
unsigned int i;
poVecSeg->GetFields( (int) nFID, aoFields );
for( i=0; i < aoFields.size(); i++ )
{
if( (int) i == iRingStartField )
continue;
switch( aoFields[i].GetType() )
{
case PCIDSK::FieldTypeNone:
// null field value.
break;
case PCIDSK::FieldTypeInteger:
poFeature->SetField( i, aoFields[i].GetValueInteger() );
break;
case PCIDSK::FieldTypeFloat:
poFeature->SetField( i, aoFields[i].GetValueFloat() );
break;
case PCIDSK::FieldTypeDouble:
poFeature->SetField( i, aoFields[i].GetValueDouble() );
break;
case PCIDSK::FieldTypeString:
poFeature->SetField( i, aoFields[i].GetValueString().c_str() );
break;
case PCIDSK::FieldTypeCountedInt:
std::vector<PCIDSK::int32> list = aoFields[i].GetValueCountedInt();
poFeature->SetField( i, list.size(), &(list[0]) );
break;
}
}
/* -------------------------------------------------------------------- */
/* Translate the geometry. */
/* -------------------------------------------------------------------- */
std::vector<PCIDSK::ShapeVertex> aoVertices;
poVecSeg->GetVertices( (int) nFID, aoVertices );
/* -------------------------------------------------------------------- */
/* Point */
/* -------------------------------------------------------------------- */
if( poFeatureDefn->GetGeomType() == wkbPoint25D
|| (wkbFlatten(poFeatureDefn->GetGeomType()) == wkbUnknown
&& aoVertices.size() == 1) )
{
if( aoVertices.size() == 1 )
{
OGRPoint* poPoint =
new OGRPoint( aoVertices[0].x,
aoVertices[0].y,
aoVertices[0].z );
if (poSRS)
poPoint->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly(poPoint);
}
else
{
// report issue?
}
}
/* -------------------------------------------------------------------- */
/* LineString */
/* -------------------------------------------------------------------- */
else if( poFeatureDefn->GetGeomType() == wkbLineString25D
|| (wkbFlatten(poFeatureDefn->GetGeomType()) == wkbUnknown
&& aoVertices.size() > 1) )
{
// We should likely be applying ringstart to break things into
// a multilinestring in some cases.
if( aoVertices.size() > 1 )
{
OGRLineString *poLS = new OGRLineString();
poLS->setNumPoints( aoVertices.size() );
for( i = 0; i < aoVertices.size(); i++ )
//.........这里部分代码省略.........
示例7: if
OGRFeature *OGRIdrisiLayer::GetNextRawFeature()
{
while(TRUE)
{
if (eGeomType == wkbPoint)
{
double dfId;
double dfX, dfY;
if (VSIFReadL(&dfId, sizeof(double), 1, fp) != 1 ||
VSIFReadL(&dfX, sizeof(double), 1, fp) != 1 ||
VSIFReadL(&dfY, sizeof(double), 1, fp) != 1)
{
return NULL;
}
CPL_LSBPTR64(&dfId);
CPL_LSBPTR64(&dfX);
CPL_LSBPTR64(&dfY);
if (m_poFilterGeom != NULL &&
(dfX < m_sFilterEnvelope.MinX ||
dfX > m_sFilterEnvelope.MaxX ||
dfY < m_sFilterEnvelope.MinY ||
dfY > m_sFilterEnvelope.MaxY))
{
nNextFID ++;
continue;
}
OGRPoint* poGeom = new OGRPoint(dfX, dfY);
if (poSRS)
poGeom->assignSpatialReference(poSRS);
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
poFeature->SetField(0, dfId);
poFeature->SetFID(nNextFID ++);
poFeature->SetGeometryDirectly(poGeom);
ReadAVLLine(poFeature);
return poFeature;
}
else if (eGeomType == wkbLineString)
{
double dfId;
double dfMinXShape, dfMaxXShape, dfMinYShape, dfMaxYShape;
unsigned int nNodes;
if (VSIFReadL(&dfId, sizeof(double), 1, fp) != 1 ||
VSIFReadL(&dfMinXShape, sizeof(double), 1, fp) != 1 ||
VSIFReadL(&dfMaxXShape, sizeof(double), 1, fp) != 1 ||
VSIFReadL(&dfMinYShape, sizeof(double), 1, fp) != 1 ||
VSIFReadL(&dfMaxYShape, sizeof(double), 1, fp) != 1)
{
return NULL;
}
CPL_LSBPTR64(&dfId);
CPL_LSBPTR64(&dfMinXShape);
CPL_LSBPTR64(&dfMaxXShape);
CPL_LSBPTR64(&dfMinYShape);
CPL_LSBPTR64(&dfMaxYShape);
if (VSIFReadL(&nNodes, sizeof(unsigned int), 1, fp) != 1)
{
return NULL;
}
CPL_LSBPTR32(&nNodes);
if (nNodes > 100 * 1000 * 1000)
return NULL;
if (m_poFilterGeom != NULL &&
(dfMaxXShape < m_sFilterEnvelope.MinX ||
dfMinXShape > m_sFilterEnvelope.MaxX ||
dfMaxYShape < m_sFilterEnvelope.MinY ||
dfMinYShape > m_sFilterEnvelope.MaxY))
{
nNextFID ++;
VSIFSeekL(fp, sizeof(OGRRawPoint) * nNodes, SEEK_CUR);
continue;
}
OGRRawPoint* poRawPoints = (OGRRawPoint*)VSIMalloc2(sizeof(OGRRawPoint), nNodes);
if (poRawPoints == NULL)
{
return NULL;
}
if ((unsigned int)VSIFReadL(poRawPoints, sizeof(OGRRawPoint), nNodes, fp) != nNodes)
{
VSIFree(poRawPoints);
return NULL;
}
#if defined(CPL_MSB)
for(unsigned int iNode=0; iNode<nNodes; iNode++)
{
CPL_LSBPTR64(&poRawPoints[iNode].x);
CPL_LSBPTR64(&poRawPoints[iNode].y);
}
#endif
OGRLineString* poGeom = new OGRLineString();
poGeom->setPoints(nNodes, poRawPoints, NULL);
//.........这里部分代码省略.........
示例8: if
OGRFeature *OGRHTFSoundingLayer::GetNextRawFeature()
{
const char* pszLine;
OGRLinearRing oLR;
while( (pszLine = CPLReadLine2L(fpHTF, 1024, NULL)) != NULL)
{
if (pszLine[0] == ';')
{
/* comment */ ;
}
else if (pszLine[0] == 0)
{
bEOF = TRUE;
return NULL;
}
else if (strcmp(pszLine, "END OF SOUNDING DATA") == 0)
{
bEOF = TRUE;
return NULL;
}
else
break;
}
if (pszLine == NULL)
{
bEOF = TRUE;
return NULL;
}
int i;
double dfEasting = 0, dfNorthing = 0;
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
char* pszStr = (char*)pszLine;
for(i=0;i<poFeatureDefn->GetFieldCount();i++)
{
if (!panFieldPresence[i])
continue;
char* pszSpace = strchr(pszStr, ' ');
if (pszSpace)
*pszSpace = '\0';
if (strcmp(pszStr, "*") != 0)
poFeature->SetField(i, pszStr);
if (i == nEastingIndex)
dfEasting = poFeature->GetFieldAsDouble(i);
else if (i == nNorthingIndex)
dfNorthing = poFeature->GetFieldAsDouble(i);
if (pszSpace == NULL)
break;
pszStr = pszSpace + 1;
}
OGRPoint* poPoint = new OGRPoint(dfEasting, dfNorthing);
poPoint->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly(poPoint);
poFeature->SetFID(nNextFID++);
return poFeature;
}
示例9: if
OGRFeature *OGRGFTLayer::BuildFeatureFromSQL(const char* pszLine)
{
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
char** papszTokens = OGRGFTCSVSplitLine(pszLine, ',');
int nTokens = CSLCount(papszTokens);
CPLString osFID;
int nAttrOffset = 0;
int iROWID = -1;
if (bFirstTokenIsFID)
{
osFID = papszTokens[0];
nAttrOffset = 1;
}
else
{
iROWID = poFeatureDefn->GetFieldIndex("rowid");
if (iROWID < 0)
iROWID = poFeatureDefn->GetFieldIndex("ROWID");
}
int nFieldCount = poFeatureDefn->GetFieldCount();
if (nTokens == nFieldCount + bHiddenGeometryField + nAttrOffset)
{
for(int i=0;i<nFieldCount+bHiddenGeometryField;i++)
{
const char* pszVal = papszTokens[i+nAttrOffset];
if (pszVal[0])
{
if (i<nFieldCount)
poFeature->SetField(i, pszVal);
if (i == iGeometryField && i != iLatitudeField)
{
if (pszVal[0] == '-' || (pszVal[0] >= '0' && pszVal[0] <= '9'))
{
char** papszLatLon = CSLTokenizeString2(pszVal, " ,", 0);
if (CSLCount(papszLatLon) == 2 &&
CPLGetValueType(papszLatLon[0]) != CPL_VALUE_STRING &&
CPLGetValueType(papszLatLon[1]) != CPL_VALUE_STRING)
{
OGRPoint* poPoint = new OGRPoint(CPLAtof( papszLatLon[1]),
CPLAtof( papszLatLon[0]));
poPoint->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly(poPoint);
}
CSLDestroy(papszLatLon);
}
else if (strstr(pszVal, "<Point>") ||
strstr(pszVal, "<LineString>") ||
strstr(pszVal, "<Polygon>"))
{
OGRGeometry* poGeom = ParseKMLGeometry(pszVal);
if (poGeom)
{
poGeom->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly(poGeom);
}
}
}
else if (i == iROWID)
{
osFID = pszVal;
}
}
}
if (iLatitudeField >= 0 && iLongitudeField >= 0)
{
const char* pszLat = papszTokens[iLatitudeField+nAttrOffset];
const char* pszLong = papszTokens[iLongitudeField+nAttrOffset];
if (pszLat[0] != 0 && pszLong[0] != 0 &&
CPLGetValueType(pszLat) != CPL_VALUE_STRING &&
CPLGetValueType(pszLong) != CPL_VALUE_STRING)
{
OGRPoint* poPoint = new OGRPoint(CPLAtof(pszLong), CPLAtof(pszLat));
poPoint->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly(poPoint);
}
}
}
else
{
CPLDebug("GFT", "Only %d columns for feature %s", nTokens, osFID.c_str());
}
CSLDestroy(papszTokens);
int nFID = atoi(osFID);
if (strcmp(CPLSPrintf("%d", nFID), osFID.c_str()) == 0)
poFeature->SetFID(nFID);
else
poFeature->SetFID(nNextInSeq);
return poFeature;
}
示例10: startElementCbk
void OGRSVGLayer::startElementCbk(const char *pszName, const char **ppszAttr)
{
int i;
if (bStopParsing) return;
nWithoutEventCounter = 0;
if (svgGeomType == SVG_POINTS &&
strcmp(pszName, "circle") == 0 &&
strcmp(OGRSVGGetClass(ppszAttr), "point") == 0)
{
int bHasFoundX = FALSE, bHasFoundY = FALSE;
double dfX = 0, dfY = 0;
for (i = 0; ppszAttr[i]; i += 2)
{
if (strcmp(ppszAttr[i], "cx") == 0)
{
bHasFoundX = TRUE;
dfX = CPLAtof(ppszAttr[i + 1]);
}
else if (strcmp(ppszAttr[i], "cy") == 0)
{
bHasFoundY = TRUE;
/* Cloudmade --> negate y */
dfY = - CPLAtof(ppszAttr[i + 1]);
}
}
if (bHasFoundX && bHasFoundY)
{
interestingDepthLevel = depthLevel;
inInterestingElement = TRUE;
if (poFeature)
delete poFeature;
poFeature = new OGRFeature( poFeatureDefn );
poFeature->SetFID( nNextFID++ );
OGRPoint* poPoint = new OGRPoint( dfX, dfY );
poPoint->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly( poPoint );
}
}
else if (svgGeomType == SVG_LINES &&
strcmp(pszName, "path") == 0 &&
strcmp(OGRSVGGetClass(ppszAttr), "line") == 0)
{
const char* pszD = NULL;
for (i = 0; ppszAttr[i]; i += 2)
{
if (strcmp(ppszAttr[i], "d") == 0)
{
pszD = ppszAttr[i + 1];
break;
}
}
if (pszD)
{
interestingDepthLevel = depthLevel;
inInterestingElement = TRUE;
if (poFeature)
delete poFeature;
poFeature = new OGRFeature( poFeatureDefn );
poFeature->SetFID( nNextFID++ );
OGRLineString* poLS = new OGRLineString();
OGRSVGParseD(poLS, pszD);
poLS->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly( poLS );
}
}
else if (svgGeomType == SVG_POLYGONS &&
strcmp(pszName, "path") == 0 &&
strcmp(OGRSVGGetClass(ppszAttr), "polygon") == 0)
{
const char* pszD = NULL;
for (i = 0; ppszAttr[i]; i += 2)
{
if (strcmp(ppszAttr[i], "d") == 0)
{
pszD = ppszAttr[i + 1];
break;
}
}
if (pszD)
{
interestingDepthLevel = depthLevel;
inInterestingElement = TRUE;
if (poFeature)
delete poFeature;
poFeature = new OGRFeature( poFeatureDefn );
poFeature->SetFID( nNextFID++ );
OGRPolygon* poPolygon = new OGRPolygon();
OGRLinearRing* poLS = new OGRLinearRing();
//.........这里部分代码省略.........