本文整理汇总了C++中OGRLinearRing::getX方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRLinearRing::getX方法的具体用法?C++ OGRLinearRing::getX怎么用?C++ OGRLinearRing::getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRLinearRing
的用法示例。
在下文中一共展示了OGRLinearRing::getX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convert_polygon
void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature)
{
OGRLinearRing* exterior = geom->getExteriorRing();
int num_points = exterior->getNumPoints();
int num_interior = geom->getNumInteriorRings();
int capacity = 0;
for (int r = 0; r < num_interior; r++)
{
OGRLinearRing* interior = geom->getInteriorRing(r);
capacity += interior->getNumPoints();
}
geometry_type* poly = new geometry_type(mapnik::Polygon);
poly->move_to(exterior->getX(0), exterior->getY(0));
for (int i = 1; i < num_points; ++i)
{
poly->line_to(exterior->getX(i), exterior->getY(i));
}
for (int r = 0; r < num_interior; r++)
{
OGRLinearRing* interior = geom->getInteriorRing(r);
num_points = interior->getNumPoints();
poly->move_to(interior->getX(0), interior->getY(0));
for (int i = 1; i < num_points; ++i)
{
poly->line_to(interior->getX(i), interior->getY(i));
}
}
feature->add_geometry(poly);
}
示例2: GeomToPoly
Polygon GeomToPoly(OGRGeometry* geometry){
OGRLinearRing *ring = dynamic_cast<OGRLinearRing *>(dynamic_cast<OGRPolygon *>(geometry)->getExteriorRing());
Polygon skeleton;
for(int i=0; i < ring->getNumPoints() - 1; i++)
if(CGAL::is_finite(ring->getX(i)) && CGAL::is_finite(ring->getY(i)))
skeleton.push_back(Point(ring->getX(i), ring->getY(i)));
return skeleton;
}
示例3: convert_polygon
void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature)
{
OGRLinearRing* exterior = geom->getExteriorRing();
int num_points = exterior->getNumPoints();
int num_interior = geom->getNumInteriorRings();
int capacity = 0;
for (int r = 0; r < num_interior; ++r)
{
OGRLinearRing* interior = geom->getInteriorRing(r);
capacity += interior->getNumPoints();
}
std::auto_ptr<geometry_type> poly(new geometry_type(mapnik::Polygon));
poly->move_to(exterior->getX(0), exterior->getY(0));
for (int i = 1; i < num_points - 1; ++i)
{
poly->line_to(exterior->getX(i), exterior->getY(i));
}
poly->close(exterior->getX(num_points-1), exterior->getY(num_points-1));
for (int r = 0; r < num_interior; ++r)
{
OGRLinearRing* interior = geom->getInteriorRing(r);
num_points = interior->getNumPoints();
poly->move_to(interior->getX(0), interior->getY(0));
for (int i = 1; i < num_points - 1; ++i)
{
poly->line_to(interior->getX(i), interior->getY(i));
}
poly->close(interior->getX(num_points-1), interior->getY(num_points-1));
}
feature->paths().push_back(poly);
}
示例4: OGRGetCentroid
int OGRGetCentroid(OGRPolygon *poPoly, OGRPoint *poCentroid)
{
int i,j;
double cent_weight_x=0.0, cent_weight_y=0.0;
double len, total_len=0;
for(i=0; i<OGR_NUM_RINGS(poPoly); i++)
{
double x1, y1, x2, y2;
OGRLinearRing *poRing = OGR_GET_RING(poPoly, i);
x2 = poRing->getX(0);
y2 = poRing->getY(0);
for(j=1; j<poRing->getNumPoints(); j++)
{
x1 = x2;
y1 = y2;
x2 = poRing->getX(j);
y2 = poRing->getY(j);
len = sqrt( pow((x2-x1),2) + pow((y2-y1),2) );
cent_weight_x += len * ((x1 + x2)/2.0);
cent_weight_y += len * ((y1 + y2)/2.0);
total_len += len;
}
}
if(total_len == 0)
return(OGRERR_FAILURE);
poCentroid->setX( cent_weight_x / total_len );
poCentroid->setY( cent_weight_y / total_len );
return OGRERR_NONE;
}
示例5: pdal_error
std::vector<Polygon::Ring> Polygon::interiorRings() const
{
std::vector<Ring> rings;
OGRwkbGeometryType t = m_geom->getGeometryType();
if (t != wkbPolygon && t != wkbPolygon25D)
throw pdal_error("Request for exterior ring on non-polygon.");
// OGRPolygon *poly = m_geom->toPolygon();
OGRPolygon *poly = static_cast<OGRPolygon *>(m_geom.get());
for (int i = 0; i < poly->getNumInteriorRings(); ++i)
{
OGRLinearRing *er = poly->getInteriorRing(i);
Ring r;
for (int j = 0; j < er->getNumPoints(); ++j)
r.push_back({er->getX(j), er->getY(j)});
rings.push_back(r);
}
return rings;
}
示例6: exteriorRing
Polygon::Ring Polygon::exteriorRing() const
{
Ring r;
OGRwkbGeometryType t = m_geom->getGeometryType();
if (t != wkbPolygon && t != wkbPolygon25D)
throw pdal_error("Request for exterior ring on non-polygon.");
// Not until GDAL 2.3
/**
OGRLinearRing *er = m_geom->toPolygon()->getExteriorRing();
// For some reason there's no operator -> on an iterator.
for (auto it = er->begin(); it != er->end(); ++it)
r.push_back({(*it).getX(), (*it).getY()});
**/
OGRLinearRing *er =
static_cast<OGRPolygon *>(m_geom.get())->getExteriorRing();
for (int i = 0; i < er->getNumPoints(); ++i)
r.push_back({er->getX(i), er->getY(i)});
return r;
}
示例7: SurfacicGraphics
MultiPolygonGraphics::MultiPolygonGraphics(OGRMultiPolygon* OGRMultiPoly, const QPen& Pen, const QBrush& Brush):
SurfacicGraphics(Brush.color())
{
QPainterPath Path;
for (int i=0; i<OGRMultiPoly->getNumGeometries();i++)
{
OGRLinearRing* LinearRing = dynamic_cast<OGRPolygon*>(OGRMultiPoly->getGeometryRef(i))->getExteriorRing();
QPolygonF Poly;
for (int i=0; i < LinearRing->getNumPoints(); i++)
Poly << QPointF(LinearRing->getX(i),LinearRing->getY(i));
Path.addPolygon(Poly);
}
setPen(Pen);
setBrush(Brush);
setPath(Path);
}
示例8: extrude_envelope
Surface* Building::extrude_envelope() const
{
Surface* envelope = new Surface(SurfaceType::Envelope,0,_length,_width,_height);
OGRLinearRing* ringFt = _footprint->getExteriorRing();
if(ringFt->isClockwise())
adjust_winding_ccw(ringFt);
envelope->addChild(new Surface(SurfaceType::Footprint,_footprint,_length,_width,0.));
//extrude roof
OGRLinearRing* ringRoof = new OGRLinearRing;
for(int i=0; i<ringFt->getNumPoints(); i++)
ringRoof->addPoint(ringFt->getX(i),ringFt->getY(i),_height);
OGRPolygon plyRoof;
plyRoof.addRingDirectly(ringRoof);
envelope->addChild(new Surface(SurfaceType::Roof,&plyRoof,_length,_width,0.));
//extrude walls
for(int i=0; i<ringFt->getNumPoints()-1; i++)
{
OGRLinearRing* ringWall = new OGRLinearRing;
ringWall->addPoint(ringFt->getX(i),ringFt->getY(i),0);
ringWall->addPoint(ringFt->getX(i+1),ringFt->getY(i+1),0);
ringWall->addPoint(ringFt->getX(i+1),ringFt->getY(i+1),_height);
ringWall->addPoint(ringFt->getX(i),ringFt->getY(i),_height);
ringWall->addPoint(ringFt->getX(i),ringFt->getY(i),0);
OGRPolygon plyWall;
plyWall.addRingDirectly(ringWall);
OGRPoint pt1(ringFt->getX(i),ringFt->getY(i),0);
OGRPoint pt2(ringFt->getX(i+1),ringFt->getY(i+1),0);
envelope->addChild(new Wall(&plyWall,pt1.Distance(&pt2),_height,&pt1,&pt2));
}
return envelope;
}
示例9: ProcessError
void
PCLoaderArcView::load(const std::string& file, OptionsCont& oc, PCPolyContainer& toFill,
PCTypeMap&) {
#ifdef HAVE_GDAL
GeoConvHelper& geoConvHelper = GeoConvHelper::getProcessing();
// get defaults
std::string prefix = oc.getString("prefix");
std::string type = oc.getString("type");
RGBColor color = RGBColor::parseColor(oc.getString("color"));
int layer = oc.getInt("layer");
std::string idField = oc.getString("shapefile.id-column");
bool useRunningID = oc.getBool("shapefile.use-running-id");
// start parsing
std::string shpName = file + ".shp";
OGRRegisterAll();
OGRDataSource* poDS = OGRSFDriverRegistrar::Open(shpName.c_str(), FALSE);
if (poDS == NULL) {
throw ProcessError("Could not open shape description '" + shpName + "'.");
}
// begin file parsing
OGRLayer* poLayer = poDS->GetLayer(0);
poLayer->ResetReading();
// build coordinate transformation
OGRSpatialReference* origTransf = poLayer->GetSpatialRef();
OGRSpatialReference destTransf;
// use wgs84 as destination
destTransf.SetWellKnownGeogCS("WGS84");
OGRCoordinateTransformation* poCT = OGRCreateCoordinateTransformation(origTransf, &destTransf);
if (poCT == NULL) {
if (oc.isSet("shapefile.guess-projection")) {
OGRSpatialReference origTransf2;
origTransf2.SetWellKnownGeogCS("WGS84");
poCT = OGRCreateCoordinateTransformation(&origTransf2, &destTransf);
}
if (poCT == 0) {
WRITE_WARNING("Could not create geocoordinates converter; check whether proj.4 is installed.");
}
}
OGRFeature* poFeature;
poLayer->ResetReading();
unsigned int runningID = 0;
while ((poFeature = poLayer->GetNextFeature()) != NULL) {
// read in edge attributes
std::string id = useRunningID ? toString(runningID) : poFeature->GetFieldAsString(idField.c_str());
++runningID;
id = StringUtils::prune(id);
if (id == "") {
throw ProcessError("Missing id under '" + idField + "'");
}
id = prefix + id;
// read in the geometry
OGRGeometry* poGeometry = poFeature->GetGeometryRef();
if (poGeometry == 0) {
OGRFeature::DestroyFeature(poFeature);
continue;
}
// try transform to wgs84
poGeometry->transform(poCT);
OGRwkbGeometryType gtype = poGeometry->getGeometryType();
switch (gtype) {
case wkbPoint: {
OGRPoint* cgeom = (OGRPoint*) poGeometry;
Position pos((SUMOReal) cgeom->getX(), (SUMOReal) cgeom->getY());
if (!geoConvHelper.x2cartesian(pos)) {
WRITE_ERROR("Unable to project coordinates for POI '" + id + "'.");
}
PointOfInterest* poi = new PointOfInterest(id, type, color, pos, (SUMOReal)layer);
if (!toFill.insert(id, poi, layer)) {
WRITE_ERROR("POI '" + id + "' could not be added.");
delete poi;
}
}
break;
case wkbLineString: {
OGRLineString* cgeom = (OGRLineString*) poGeometry;
PositionVector shape;
for (int j = 0; j < cgeom->getNumPoints(); j++) {
Position pos((SUMOReal) cgeom->getX(j), (SUMOReal) cgeom->getY(j));
if (!geoConvHelper.x2cartesian(pos)) {
WRITE_ERROR("Unable to project coordinates for polygon '" + id + "'.");
}
shape.push_back_noDoublePos(pos);
}
Polygon* poly = new Polygon(id, type, color, shape, false, (SUMOReal)layer);
if (!toFill.insert(id, poly, layer)) {
WRITE_ERROR("Polygon '" + id + "' could not be added.");
delete poly;
}
}
break;
case wkbPolygon: {
OGRLinearRing* cgeom = ((OGRPolygon*) poGeometry)->getExteriorRing();
PositionVector shape;
for (int j = 0; j < cgeom->getNumPoints(); j++) {
Position pos((SUMOReal) cgeom->getX(j), (SUMOReal) cgeom->getY(j));
if (!geoConvHelper.x2cartesian(pos)) {
WRITE_ERROR("Unable to project coordinates for polygon '" + id + "'.");
//.........这里部分代码省略.........
示例10: if
//.........这里部分代码省略.........
if (bHasCenter && CSLCount(papszTokens) == 3)
{
double dfRadius = atof(papszTokens[0]) * 1852;
double dfStartAngle = atof(papszTokens[1]);
double dfEndAngle = atof(papszTokens[2]);
if (bClockWise && dfEndAngle < dfStartAngle)
dfEndAngle += 360;
else if (!bClockWise && dfStartAngle < dfEndAngle)
dfEndAngle -= 360;
double dfStartDistance = dfRadius;
double dfEndDistance = dfRadius;
int nSign = (bClockWise) ? 1 : -1;
double dfAngle;
double dfLat, dfLon;
for(dfAngle = dfStartAngle;
(dfAngle - dfEndAngle) * nSign < 0;
dfAngle += nSign)
{
double pct = (dfAngle - dfStartAngle) /
(dfEndAngle - dfStartAngle);
double dfDist = dfStartDistance * (1-pct) +
dfEndDistance * pct;
OGRXPlane_ExtendPosition(dfCenterLat, dfCenterLon,
dfDist, dfAngle, &dfLat, &dfLon);
oLR.addPoint(dfLon, dfLat);
}
OGRXPlane_ExtendPosition(dfCenterLat, dfCenterLon,
dfEndDistance, dfEndAngle, &dfLat, &dfLon);
oLR.addPoint(dfLon, dfLat);
dfLastLat = oLR.getY(oLR.getNumPoints() - 1);
dfLastLon = oLR.getX(oLR.getNumPoints() - 1);
}
CSLDestroy(papszTokens);
}
else if (EQUALN(pszLine, "DB ", 3))
{
pszLine += 3;
char* pszStar = strchr((char*)pszLine, '*');
if (pszStar) *pszStar = 0;
char** papszTokens = CSLTokenizeString2(pszLine, ",", 0);
double dfFirstLat, dfFirstLon;
double dfSecondLat, dfSecondLon;
if (bHasCenter && CSLCount(papszTokens) == 2 &&
OGROpenAirGetLatLon(papszTokens[0], dfFirstLat, dfFirstLon) &&
OGROpenAirGetLatLon(papszTokens[1], dfSecondLat, dfSecondLon))
{
double dfStartDistance =OGRXPlane_Distance(dfCenterLat,
dfCenterLon, dfFirstLat, dfFirstLon);
double dfEndDistance = OGRXPlane_Distance(dfCenterLat,
dfCenterLon, dfSecondLat, dfSecondLon);
double dfStartAngle = OGRXPlane_Track(dfCenterLat,
dfCenterLon, dfFirstLat, dfFirstLon);
double dfEndAngle = OGRXPlane_Track(dfCenterLat,
dfCenterLon, dfSecondLat, dfSecondLon);
if (bClockWise && dfEndAngle < dfStartAngle)
dfEndAngle += 360;
else if (!bClockWise && dfStartAngle < dfEndAngle)
dfEndAngle -= 360;
int nSign = (bClockWise) ? 1 : -1;
double dfAngle;
示例11: switch
OGRErr
OGROCIWritableLayer::TranslateElementGroup( OGRGeometry *poGeometry )
{
switch( wkbFlatten(poGeometry->getGeometryType()) )
{
case wkbPoint:
{
OGRPoint *poPoint = (OGRPoint *) poGeometry;
PushElemInfo( nOrdinalCount+1, 1, 1 );
PushOrdinal( poPoint->getX() );
PushOrdinal( poPoint->getY() );
if( nDimension == 3 )
PushOrdinal( poPoint->getZ() );
return OGRERR_NONE;
}
case wkbLineString:
{
OGRLineString *poLine = (OGRLineString *) poGeometry;
int iVert;
PushElemInfo( nOrdinalCount+1, 2, 1 );
for( iVert = 0; iVert < poLine->getNumPoints(); iVert++ )
{
PushOrdinal( poLine->getX(iVert) );
PushOrdinal( poLine->getY(iVert) );
if( nDimension == 3 )
PushOrdinal( poLine->getZ(iVert) );
}
return OGRERR_NONE;
}
case wkbPolygon:
{
OGRPolygon *poPoly = (OGRPolygon *) poGeometry;
int iRing;
for( iRing = -1; iRing < poPoly->getNumInteriorRings(); iRing++ )
{
OGRLinearRing *poRing;
int iVert;
if( iRing == -1 )
poRing = poPoly->getExteriorRing();
else
poRing = poPoly->getInteriorRing(iRing);
if( iRing == -1 )
PushElemInfo( nOrdinalCount+1, 1003, 1 );
else
PushElemInfo( nOrdinalCount+1, 2003, 1 );
if( (iRing == -1 && poRing->isClockwise())
|| (iRing != -1 && !poRing->isClockwise()) )
{
for( iVert = poRing->getNumPoints()-1; iVert >= 0; iVert-- )
{
PushOrdinal( poRing->getX(iVert) );
PushOrdinal( poRing->getY(iVert) );
if( nDimension == 3 )
PushOrdinal( poRing->getZ(iVert) );
}
}
else
{
for( iVert = 0; iVert < poRing->getNumPoints(); iVert++ )
{
PushOrdinal( poRing->getX(iVert) );
PushOrdinal( poRing->getY(iVert) );
if( nDimension == 3 )
PushOrdinal( poRing->getZ(iVert) );
}
}
}
return OGRERR_NONE;
}
default:
{
return OGRERR_FAILURE;
}
}
}
示例12: WriteHATCH
//.........这里部分代码省略.........
{
osLineType = (*it).first;
break;
}
}
// create an automatic name for it.
if( osLineType == "" )
{
do
{
osLineType.Printf( "AutoLineType-%d", nNextAutoID++ );
}
while( poDS->oHeaderDS.LookupLineType(osLineType) != NULL );
}
}
// If it isn't already defined, add it now.
if( osDefinition != "" && oNewLineTypes.count(osLineType) == 0 )
{
oNewLineTypes[osLineType] = osDefinition;
WriteValue( 6, osLineType );
}
}
delete poTool;
#endif
/* -------------------------------------------------------------------- */
/* Process the loops (rings). */
/* -------------------------------------------------------------------- */
OGRPolygon *poPoly = (OGRPolygon *) poGeom;
WriteValue( 91, poPoly->getNumInteriorRings() + 1 );
for( int iRing = -1; iRing < poPoly->getNumInteriorRings(); iRing++ )
{
OGRLinearRing *poLR;
if( iRing == -1 )
poLR = poPoly->getExteriorRing();
else
poLR = poPoly->getInteriorRing( iRing );
WriteValue( 92, 2 ); // Polyline
WriteValue( 72, 0 ); // has bulge
WriteValue( 73, 1 ); // is closed
WriteValue( 93, poLR->getNumPoints() );
for( int iVert = 0; iVert < poLR->getNumPoints(); iVert++ )
{
WriteValue( 10, poLR->getX(iVert) );
WriteValue( 20, poLR->getY(iVert) );
}
WriteValue( 97, 0 ); // 0 source boundary objects
}
WriteValue( 75, 0 ); // hatch style = Hatch "odd parity" area (Normal style)
WriteValue( 76, 1 ); // hatch pattern type = predefined
WriteValue( 98, 0 ); // 0 seed points
return OGRERR_NONE;
#ifdef notdef
/* -------------------------------------------------------------------- */
/* Alternate unmaintained implementation as a polyline entity. */
/* -------------------------------------------------------------------- */
WriteValue( 0, "POLYLINE" );
WriteCore( poFeature );
WriteValue( 100, "AcDbEntity" );
WriteValue( 100, "AcDbPolyline" );
if( EQUAL( poGeom->getGeometryName(), "LINEARRING" ) )
WriteValue( 70, 1 );
else
WriteValue( 70, 0 );
WriteValue( 66, "1" );
int iVert;
for( iVert = 0; iVert < poLS->getNumPoints(); iVert++ )
{
WriteValue( 0, "VERTEX" );
WriteValue( 8, "0" );
WriteValue( 10, poLS->getX(iVert) );
if( !WriteValue( 20, poLS->getY(iVert) ) )
return OGRERR_FAILURE;
if( poLS->getGeometryType() == wkbLineString25D )
{
if( !WriteValue( 30, poLS->getZ(iVert) ) )
return OGRERR_FAILURE;
}
}
WriteValue( 0, "SEQEND" );
WriteValue( 8, "0" );
return OGRERR_NONE;
#endif
}
示例13: paintMap
//.........这里部分代码省略.........
painter.setFont(*font);
painter.setPen(pen);
painter.setBrush(brush);
WPainterPath path;
poLayer->ResetReading();
OGRPoint *centroid = new OGRPoint();
char label[100];
while( (poFeature = poLayer->GetNextFeature()) != NULL )
{
centroid->empty();
label[0]=0;
if(labelindex>0)
{
OGRFeatureDefn *PointFDefn = poLayer->GetLayerDefn();
OGRFieldDefn *PointFieldDefn = PointFDefn->GetFieldDefn(labelindex-1);
if( PointFieldDefn->GetType() == OFTInteger )
sprintf(label, "%d", poFeature->GetFieldAsInteger(labelindex-1) );
else if( PointFieldDefn->GetType() == OFTReal )
sprintf(label, "%.3f", poFeature->GetFieldAsDouble(labelindex-1) );
else if( PointFieldDefn->GetType() == OFTString )
sprintf(label, "%s", poFeature->GetFieldAsString(labelindex-1) );
else
sprintf(label, "%s", poFeature->GetFieldAsString(labelindex-1) );
}
OGRGeometry *poGeometry;
poGeometry = poFeature->GetGeometryRef();
if( poGeometry != NULL && wkbFlatten(poGeometry->getGeometryType()) == wkbPoint )
{
OGRPoint *poPoint = (OGRPoint *) poGeometry;
double x = poPoint->getX();
double y = poPoint->getY();
//painter.drawPoint(x/scaleFactor,y/scaleFactor);
painter.drawEllipse(x/scaleFactor-0.005*gWidth*widthFactor,y/scaleFactor-0.005*gWidth*widthFactor,0.01*gWidth*widthFactor,0.01*gWidth*widthFactor);
poGeometry->Centroid(centroid);
} //end wkbpoint
else if( poGeometry != NULL && wkbFlatten(poGeometry->getGeometryType()) == wkbLineString )
{
OGRLineString *poPoint = (OGRLineString *) poGeometry;
for(int i=0;i<poPoint->getNumPoints();i++)
{
double x=poPoint->getX(i) ;
double y = poPoint->getY(i);
x/=scaleFactor; y/=scaleFactor;
if(i==0)
path = WPainterPath( WPointF(x, y));
else
path.lineTo( x , y);
}
painter.drawPath(path);
poGeometry->Centroid(centroid);
}
else if( (poGeometry != NULL) && wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon)
{
OGRPolygon *poPoint = (OGRPolygon *) poGeometry;
OGRLinearRing *extring = poPoint->getExteriorRing();
示例14: extrude_box
OGRMultiPolygon* Building::extrude_box() const
{
OGRMultiPolygon* block = new OGRMultiPolygon;
//extrude roof
OGRPolygon roof;
{
roof.addRing(_footprint->getExteriorRing());
OGRLinearRing* ring = roof.getExteriorRing();
for(int i=0; i<ring->getNumPoints(); i++)
ring->setPoint(i,ring->getX(i),ring->getY(i),_height);
}
if(int n = _footprint->getNumInteriorRings())
{
for (int j=0; j<n; j++)
{
roof.addRing(_footprint->getInteriorRing(j));
OGRLinearRing* ring = roof.getInteriorRing(j);
for(int i=0; i<ring->getNumPoints(); i++)
ring->setPoint(i,ring->getX(i),ring->getY(i),_height);
}
}
block->addGeometry(&roof);
//extrude exter walls
OGRLinearRing* ringEx = _footprint->getExteriorRing();
for(int i=0; i<ringEx->getNumPoints()-1; i++)
{
OGRPolygon wall;
OGRLinearRing ring;
ring.addPoint(ringEx->getX(i),ringEx->getY(i),0);
ring.addPoint(ringEx->getX(i+1),ringEx->getY(i+1),0);
ring.addPoint(ringEx->getX(i+1),ringEx->getY(i+1),_height);
ring.addPoint(ringEx->getX(i),ringEx->getY(i),_height);
ring.addPoint(ringEx->getX(i),ringEx->getY(i),0);
wall.addRing(&ring);
block->addGeometry(&wall);
}
//extrude inner walls if exist
if(int n = _footprint->getNumInteriorRings())
{
for (int i=0; i<n; i++)
{
OGRLinearRing* ringIn = _footprint->getInteriorRing(i);
for(int j=0; j<ringIn->getNumPoints()-1; j++)
{
OGRPolygon wall;
OGRLinearRing ring;
ring.addPoint(ringIn->getX(j),ringIn->getY(j),0);
ring.addPoint(ringIn->getX(j+1),ringIn->getY(j+1),0);
ring.addPoint(ringIn->getX(j+1),ringIn->getY(j+1),_height);
ring.addPoint(ringIn->getX(j),ringIn->getY(j),_height);
ring.addPoint(ringIn->getX(j),ringIn->getY(j),0);
wall.addRing(&ring);
block->addGeometry(&wall);
}
}
}
return block;
}
示例15: PrepareOldStyleGeometry
OGRErr OGRIngresTableLayer::PrepareOldStyleGeometry(
OGRGeometry *poGeom, CPLString &osRetGeomText )
{
osRetGeomText = "";
if( poGeom == NULL )
return OGRERR_FAILURE;
/* -------------------------------------------------------------------- */
/* Point */
/* -------------------------------------------------------------------- */
if( EQUAL(osIngresGeomType,"POINT")
&& wkbFlatten(poGeom->getGeometryType()) == wkbPoint )
{
OGRPoint *poPoint = (OGRPoint *) poGeom;
osRetGeomText.Printf( "(%.15g,%.15g)", poPoint->getX(), poPoint->getY() );
return OGRERR_NONE;
}
if( EQUAL(osIngresGeomType,"IPOINT")
&& wkbFlatten(poGeom->getGeometryType()) == wkbPoint )
{
OGRPoint *poPoint = (OGRPoint *) poGeom;
osRetGeomText.Printf( "(%d,%d)",
(int) floor(poPoint->getX()),
(int) floor(poPoint->getY()) );
return OGRERR_NONE;
}
/* -------------------------------------------------------------------- */
/* Line */
/* -------------------------------------------------------------------- */
if( wkbFlatten(poGeom->getGeometryType()) == wkbLineString )
{
OGRLineString *poLS = (OGRLineString *) poGeom;
CPLString osLastPoint;
int i;
if( (EQUAL(osIngresGeomType,"LSEG")
|| EQUAL(osIngresGeomType,"ILSEG"))
&& poLS->getNumPoints() != 2 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Attempt to place %d vertex linestring in %s field.",
poLS->getNumPoints(),
osIngresGeomType.c_str() );
return OGRERR_FAILURE;
}
else if( EQUAL(osIngresGeomType,"LINESTRING")
&& poLS->getNumPoints() > 124 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Attempt to place %d vertex linestring in %s field.",
poLS->getNumPoints(),
osIngresGeomType.c_str() );
return OGRERR_FAILURE;
}
else if( EQUAL(osIngresGeomType,"ILINESTRING")
&& poLS->getNumPoints() > 248 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Attempt to place %d vertex linestring in %s field.",
poLS->getNumPoints(),
osIngresGeomType.c_str() );
return OGRERR_FAILURE;
}
osRetGeomText = "(";
for( i = 0; i < poLS->getNumPoints(); i++ )
{
CPLString osPoint;
if( i > 0
&& poLS->getX(i) == poLS->getX(i-1)
&& poLS->getY(i) == poLS->getY(i-1) )
{
CPLDebug( "INGRES", "Dropping duplicate point in linestring.");
continue;
}
if( EQUALN(osIngresGeomType,"I",1) )
osPoint.Printf( "(%d,%d)",
(int) floor(poLS->getX(i)),
(int) floor(poLS->getY(i)) );
else
osPoint.Printf( "(%.15g,%.15g)",
poLS->getX(i), poLS->getY(i) );
if( osPoint == osLastPoint )
{
CPLDebug( "INGRES",
"Dropping duplicate point in linestring(2).");
continue;
}
osLastPoint = osPoint;
if( osRetGeomText.size() > 1 )
//.........这里部分代码省略.........