当前位置: 首页>>代码示例>>C++>>正文


C++ OGRPoint::setX方法代码示例

本文整理汇总了C++中OGRPoint::setX方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRPoint::setX方法的具体用法?C++ OGRPoint::setX怎么用?C++ OGRPoint::setX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OGRPoint的用法示例。


在下文中一共展示了OGRPoint::setX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: features_at_point

featureset_ptr ogr_datasource::features_at_point(coord2d const& pt) const
{
    if (!is_bound_) bind();
   
    if (dataset_ && layer_.is_valid())
    {
        OGRLayer* layer = layer_.layer();

        if (indexed_)
        {
            filter_at_point filter(pt);
            
            return featureset_ptr(new ogr_index_featureset<filter_at_point> (*dataset_,
                                                                             *layer,
                                                                             filter,
                                                                             index_name_,
                                                                             desc_.get_encoding(),
                                                                             multiple_geometries_));
        }
        else
        {
            OGRPoint point;
            point.setX (pt.x);
            point.setY (pt.y);

            return featureset_ptr(new ogr_featureset (*dataset_,
                                                      *layer,
                                                      point,
                                                      desc_.get_encoding(),
                                                      multiple_geometries_));
        }
    }

    return featureset_ptr();
}
开发者ID:ParveenArora,项目名称:mapnik,代码行数:35,代码来源:ogr_datasource.cpp

示例2: OGRPoint

OGRPoint *getARCCenter(OGRPoint *ptStart, OGRPoint *ptArc, OGRPoint *ptEnd) {
  // FIXME precision
  double bx = ptStart->getX(); double by = ptStart->getY();
  double cx = ptArc->getX(); double cy = ptArc->getY();
  double dx = ptEnd->getX(); double dy = ptEnd->getY();
  double temp, bc, cd, det, x, y;

  temp = cx*cx+cy*cy;
  bc = (bx*bx + by*by - temp)/2.0;
  cd = (temp - dx*dx - dy*dy)/2.0;
  det = (bx-cx)*(cy-dy)-(cx-dx)*(by-cy);

  OGRPoint *center = new OGRPoint();

  if (fabs(det) < 1.0e-6) { // could not determin the determinante: too small
    return center;
  }
  det = 1/det;
  x = (bc*(cy-dy)-cd*(by-cy))*det;
  y = ((bx-cx)*cd-(cx-dx)*bc)*det;

  center->setX(x);
  center->setY(y);

  return center;
}
开发者ID:imincik,项目名称:pkg-gdal,代码行数:26,代码来源:ilihelper.cpp

示例3: ogrfeature

      ogrfeature(const xyh point):
	poFeature(OGRFeature::CreateFeature( poLayer->getLayerDefn() ))
      {
	poFeature->SetField( "Height", point.value);
	OGRPoint pt; // destroy ??
	pt.setX( point.row );
	pt.setY( point.col );
	poFeature->SetGeometry( &pt );
      }
开发者ID:ehelle,项目名称:spotgen,代码行数:9,代码来源:gdal-cpp-wrapper.hpp

示例4: if

OGRCircularString *ILI2Reader::getArc(DOMElement *elem) {
  // elem -> ARC
  OGRCircularString *arc = new OGRCircularString();
  // previous point -> start point
  OGRPoint *ptStart = getPoint((DOMElement *)elem->getPreviousSibling()); // COORD or ARC
  // end point
  OGRPoint *ptEnd = new OGRPoint();
  // point on the arc
  OGRPoint *ptOnArc = new OGRPoint();
  // double radius = 0; // radius

  DOMElement *arcElem = (DOMElement *)elem->getFirstChild();
  while (arcElem != NULL) {
    char* pszTagName = XMLString::transcode(arcElem->getTagName());
    char* pszObjValue = getObjValue(arcElem);
    if (cmpStr("C1", pszTagName) == 0)
      ptEnd->setX(CPLAtof(pszObjValue));
    else if (cmpStr("C2", pszTagName) == 0)
      ptEnd->setY(CPLAtof(pszObjValue));
    else if (cmpStr("C3", pszTagName) == 0)
      ptEnd->setZ(CPLAtof(pszObjValue));
    else if (cmpStr("A1", pszTagName) == 0)
      ptOnArc->setX(CPLAtof(pszObjValue));
    else if (cmpStr("A2", pszTagName) == 0)
      ptOnArc->setY(CPLAtof(pszObjValue));
    else if (cmpStr("A3", pszTagName) == 0)
      ptOnArc->setZ(CPLAtof(pszObjValue));
    else if (cmpStr("R", pszTagName) == 0) {
      // radius = CPLAtof(pszObjValue);
    }
    CPLFree(pszObjValue);
    XMLString::release(&pszTagName);
    arcElem = (DOMElement *)arcElem->getNextSibling();
  }
  arc->addPoint(ptStart);
  arc->addPoint(ptOnArc);
  arc->addPoint(ptEnd);
  delete ptStart;
  delete ptOnArc;
  delete ptEnd;
  return arc;
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:42,代码来源:ili2reader.cpp

示例5: if

OGRLineString *ILI2Reader::getArc(DOMElement *elem) {
  // elem -> ARC
  OGRLineString *ls = new OGRLineString();
  // previous point -> start point
  OGRPoint *ptStart = getPoint((DOMElement *)elem->getPreviousSibling()); // COORD or ARC
  // end point
  OGRPoint *ptEnd = new OGRPoint();
  // point on the arc
  OGRPoint *ptOnArc = new OGRPoint();
  double radius = 0; // radius

  DOMElement *arcElem = (DOMElement *)elem->getFirstChild();
  while (arcElem != NULL) {
    char* pszTagName = XMLString::transcode(arcElem->getTagName());
    char* pszObjValue = getObjValue(arcElem);
    if (cmpStr("C1", pszTagName) == 0)
      ptEnd->setX(atof(pszObjValue));
    else if (cmpStr("C2", pszTagName) == 0)
      ptEnd->setY(atof(pszObjValue));
    else if (cmpStr("C3", pszTagName) == 0)
      ptEnd->setZ(atof(pszObjValue));
    else if (cmpStr("A1", pszTagName) == 0)
      ptOnArc->setX(atof(pszObjValue));
    else if (cmpStr("A2", pszTagName) == 0)
      ptOnArc->setY(atof(pszObjValue));
    else if (cmpStr("A3", pszTagName) == 0)
      ptOnArc->setZ(atof(pszObjValue));
    else if (cmpStr("R", pszTagName) == 0)
      radius = atof(pszObjValue);
    CPLFree(pszObjValue);
    XMLString::release(&pszTagName);
    arcElem = (DOMElement *)arcElem->getNextSibling();
  }
  ptEnd->flattenTo2D();
  ptOnArc->flattenTo2D();
  interpolateArc(ls, ptStart, ptOnArc, ptEnd, arcIncr);
  delete ptStart;
  delete ptOnArc;
  delete ptEnd;
  return ls;
}
开发者ID:imincik,项目名称:pkg-gdal,代码行数:41,代码来源:ili2reader.cpp

示例6: run

void GDALAddComponentViewContainer::run()
{
	int counter = 0;
	for (int i = 0; i < elements; i++) {
		OGRFeature * f = this->components.createFeature();
		f->SetField("persons", "that is me");
		OGRPoint pt;
		pt.setX( i );
		pt.setY( i );

		f->SetGeometry(&pt);
		if (counter == 100000) {
			counter = 0;
		}
		counter++;
	}
}
开发者ID:christianurich,项目名称:DynaMind-ToolBox,代码行数:17,代码来源:gdaladdcomponentviewcontainer.cpp

示例7: features_at_point

featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) const
{
    if (!is_bound_) bind();

#ifdef MAPNIK_STATS
    mapnik::progress_timer __stats__(std::clog, "ogr_datasource::features_at_point");
#endif

    if (dataset_ && layer_.is_valid())
    {
        std::vector<attribute_descriptor> const& desc_ar = desc_.get_descriptors();
        // feature context (schema)
        mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();

        std::vector<attribute_descriptor>::const_iterator itr = desc_ar.begin();
        std::vector<attribute_descriptor>::const_iterator end = desc_ar.end();
        for (; itr!=end; ++itr) ctx->push(itr->get_name());

        OGRLayer* layer = layer_.layer();

        if (indexed_)
        {
            filter_at_point filter(pt);

            return featureset_ptr(new ogr_index_featureset<filter_at_point> (ctx,
                                                                             *layer,
                                                                             filter,
                                                                             index_name_,
                                                                             desc_.get_encoding()));
        }
        else
        {
            OGRPoint point;
            point.setX (pt.x);
            point.setY (pt.y);

            return featureset_ptr(new ogr_featureset (ctx,
                                                      *layer,
                                                      point,
                                                      desc_.get_encoding()));
        }
    }

    return featureset_ptr();
}
开发者ID:PaulWagener,项目名称:mapnik,代码行数:45,代码来源:ogr_datasource.cpp

示例8: AddPoint

static int AddPoint( OGRGeometry *poGeometry, 
                     double dfX, double dfY, double dfZ, int nDimension )

{
    if( poGeometry->getGeometryType() == wkbPoint 
        || poGeometry->getGeometryType() == wkbPoint25D )
    {
        OGRPoint *poPoint = (OGRPoint *) poGeometry;

        if( poPoint->getX() != 0.0 || poPoint->getY() != 0.0 )
        {
            CPLError( CE_Failure, CPLE_AppDefined, 
                      "More than one coordinate for <Point> element.");
            return FALSE;
        }
            
        poPoint->setX( dfX );
        poPoint->setY( dfY );
        if( nDimension == 3 )
            poPoint->setZ( dfZ );

        return TRUE;
    }
                
    else if( poGeometry->getGeometryType() == wkbLineString
             || poGeometry->getGeometryType() == wkbLineString25D )
    {
        if( nDimension == 3 )
            ((OGRLineString *) poGeometry)->addPoint( dfX, dfY, dfZ );
        else
            ((OGRLineString *) poGeometry)->addPoint( dfX, dfY );

        return TRUE;
    }

    else
    {
        CPLAssert( FALSE );
        return FALSE;                                                   
    }
}
开发者ID:maowang,项目名称:sqlite-ogc,代码行数:41,代码来源:gml2ogrgeometry.cpp

示例9: report_raster_data_within_polygon

void report_raster_data_within_polygon(Raster* raster, OGRPolygon* poPolygon, int feature_num, string feature_name) {
    if (raster->rasterBBox->Intersects( poPolygon ) ) {
        OGRPolygon *poIntersection = (OGRPolygon*) raster->rasterBBox->Intersection( poPolygon );
        OGREnvelope* envl = new OGREnvelope;
        poIntersection->getEnvelope(envl);
        //printf ("Bounding rect (minX, maxX; minY, maxY): %.3f, %.3f; %.3f, %.3f\n", envl->MinX, envl->MaxX, envl->MinY, envl->MaxY);
        const double pw = raster->pixel_width;
        const double ph = raster->pixel_height;
        int pixelOffset_X = round((envl->MinX - raster->upper_left_x) / pw);
        int pixelOffset_Y = round((raster->upper_left_y - envl->MaxY) / ph);
        int nCellsX = round((envl->MaxX - raster->upper_left_x) / pw) - pixelOffset_X;
        int nCellsY = round((raster->upper_left_y - envl->MinY) / ph) - pixelOffset_Y;
        OGRPoint* pixelPoint = new OGRPoint(0,0);

        float* pPixelValue = (float *) CPLMalloc(sizeof(float));

        cerr << "Feature size: " << nCellsX << "x" << nCellsY << endl;
        for ( int row = 0; row < nCellsY; ++row ) {
            for ( int col = 0; col < nCellsX; ++col ) {
                double xcenter = (col + pixelOffset_X + 0.5)*pw + raster->upper_left_x;
                double ycenter = raster->upper_left_y - (row + pixelOffset_Y + 0.5)*ph;

                pixelPoint->setX(xcenter);
                pixelPoint->setY(ycenter);

                if ( pixelPoint->Intersects(poPolygon)) {
                    raster->band->RasterIO( GF_Read, pixelOffset_X + col, pixelOffset_Y + row, 1,1,  pPixelValue, 1,1, GDT_Float32, 0, 0 );
                    cout << setprecision(10) << xcenter << "," << setprecision(10) <<  ycenter << "," <<  *pPixelValue << "," << feature_num << ","  << feature_name << endl;
                } 
            }
        }
        delete envl;
        CPLFree(pPixelValue);
    } else {
        cerr << "Feature does not intersect raster" << endl;
    }
    return;
}
开发者ID:PulliamLab-UFL,项目名称:dengue,代码行数:38,代码来源:clip_raster_by_region.cpp

示例10: run

void GDALAddComponent::run()
{
	DM::GDALSystem * sys = this->getGDALData("city");
	sys->updateView(components);

	this->components.setCurrentGDALSystem(sys);

	int counter = 0;
	for (int i = 0; i < elements; i++) {
		OGRFeature * f = this->components.createFeature();

		if (addAttributes) {
			std::vector<double> double_vector;
			f->SetField("double_attribute", 10.5);
			double_vector.push_back(10.5);
			double_vector.push_back(20.5);
			double_vector.push_back(30.5);
			DM::DMFeature::SetDoubleList( f, "double_vector_attribute", double_vector);

		}
		//f->SetField("persons", "that is me");
		OGRPoint pt;
		pt.setX( i );
		pt.setY( i );

		f->SetGeometry(&pt);
		if (counter == 100000) {
			components.syncAlteredFeatures();
			counter = 0;
		}
		counter++;
	}
	this->components.syncAlteredFeatures();


}
开发者ID:christianurich,项目名称:DynaMind-ToolBox,代码行数:36,代码来源:gdaladdcomponent.cpp

示例11: OGRPoint


//.........这里部分代码省略.........
            poFeature->SetGeometryDirectly( poLS );
            poFeature->SetField( FIELD_NAME_GEOMTYPE, "CADLine" );
            break;
        }

        case CADGeometry::SOLID:
        {
            CADSolid * const poCADSolid = ( CADSolid* ) poCADGeometry;
            OGRPolygon * poPoly = new OGRPolygon();
            OGRLinearRing * poLR = new OGRLinearRing();

            std::vector<CADVector> astSolidCorners = poCADSolid->getCorners();
            for( size_t i = 0; i < astSolidCorners.size(); ++i )
            {
                poLR->addPoint( astSolidCorners[i].getX(),
                                astSolidCorners[i].getY(),
                                astSolidCorners[i].getZ());
            }
            poPoly->addRingDirectly( poLR );
            poPoly->closeRings();
            poFeature->SetGeometryDirectly( poPoly );

            poFeature->SetField( FIELD_NAME_GEOMTYPE, "CADSolid" );
            break;
        }

        case CADGeometry::CIRCLE:
        {
            CADCircle * poCADCircle = static_cast<CADCircle*>(poCADGeometry);
            OGRCircularString * poCircle = new OGRCircularString();

            CADVector stCircleCenter = poCADCircle->getPosition();
            OGRPoint  oCirclePoint1;
            oCirclePoint1.setX( stCircleCenter.getX() - poCADCircle->getRadius() );
            oCirclePoint1.setY( stCircleCenter.getY() );
            oCirclePoint1.setZ( stCircleCenter.getZ() );
            poCircle->addPoint( &oCirclePoint1 );

            OGRPoint  oCirclePoint2;
            oCirclePoint2.setX( stCircleCenter.getX() );
            oCirclePoint2.setY( stCircleCenter.getY() + poCADCircle->getRadius() );
            oCirclePoint2.setZ( stCircleCenter.getZ() );
            poCircle->addPoint( &oCirclePoint2 );

            OGRPoint  oCirclePoint3;
            oCirclePoint3.setX( stCircleCenter.getX() + poCADCircle->getRadius() );
            oCirclePoint3.setY( stCircleCenter.getY() );
            oCirclePoint3.setZ( stCircleCenter.getZ() );
            poCircle->addPoint( &oCirclePoint3 );

            OGRPoint  oCirclePoint4;
            oCirclePoint4.setX( stCircleCenter.getX() );
            oCirclePoint4.setY( stCircleCenter.getY() - poCADCircle->getRadius() );
            oCirclePoint4.setZ( stCircleCenter.getZ() );
            poCircle->addPoint( &oCirclePoint4 );

            // Close the circle
            poCircle->addPoint( &oCirclePoint1 );

            /*NOTE: The alternative way:
                    OGRGeometry *poCircle = OGRGeometryFactory::approximateArcAngles(
                    poCADCircle->getPosition().getX(),
                    poCADCircle->getPosition().getY(),
                    poCADCircle->getPosition().getZ(),
                    poCADCircle->getRadius(), poCADCircle->getRadius(), 0.0,
                    0.0, 360.0,
开发者ID:OSGeo,项目名称:gdal,代码行数:67,代码来源:ogrcadlayer.cpp

示例12: loaded


//.........这里部分代码省略.........

               point = point_next;
               //std::cout << "Boundary trace: s: " << s << ", x: " << x << ", y:"  << y << ", tile min: (" << tileXMin << ", " << tileYMin << "), max: (" << tileXMax << ", " << tileYMax << ")" << std::endl;

               osg::BoundingBox tileBB(tileXMin, tileYMin, -1.0, tileXMax, tileYMax, 1.0);
               if(tileBB.contains(osg::Vec3(x,y,0.0))) {
                  osg::PositionAttitudeTransform* treeTrans = new osg::PositionAttitudeTransform();
                  treeGroup->addChild(treeTrans);
                  //hflayer->getInterpolatedValue(x,y,z);
                  int x_int = floor((x-tileXMin)/tileXInterval+0.5);
                  if(x_int<0) x_int=0; else if(x_int>=field->getNumColumns()) x_int=field->getNumColumns()-1;
                  int y_int = floor((y-tileYMin)/tileYInterval+0.5);
                  if(y_int<0) y_int=0; else if(y_int>=field->getNumRows()) y_int=field->getNumRows()-1;
                  double z = field->getHeight(x_int,y_int);

                  //osg::Vec3 treePos(x,y,z);
                  osg::Vec3 treePos(point.getX(),point.getY(),z);
                  treeTrans->setPosition(treePos);
                  int treeIt = (int)floor(mt()*(double)treeNodeVector.size());
                  treeTrans->addChild(treeNodeVector[treeIt].get());
                  treeTrans->setName("TreeTransform");
               }
            }*/


            OGREnvelope psEnvelope;
            poPolygon->getEnvelope(&psEnvelope);
            int nTrees = (int)((psEnvelope.MaxX-psEnvelope.MinX)*(psEnvelope.MaxY-psEnvelope.MinY)*1e-5/tileElementArea);
            for(int i = 0; i<nTrees; ++i)
            {
               OGRPoint point;
               //point.setX(mt()*(psEnvelope.MaxX-psEnvelope.MinX) + psEnvelope.MinX);
               //point.setY(mt()*(psEnvelope.MaxY-psEnvelope.MinY) + psEnvelope.MinY);
               point.setX(mt()*(tileXMax-tileXMin) + tileXMin);
               point.setY(mt()*(tileYMax-tileYMin) + tileYMin);
               //if(poPolygon->Contains(&point)) {
                  osg::PositionAttitudeTransform* treeTrans = new osg::PositionAttitudeTransform();
                  treeGroup->addChild(treeTrans);
                  //hflayer->getInterpolatedValue(x,y,z);
                  double x = point.getX() + offset.x();
                  double y = point.getY() + offset.y();
                  int x_int = floor((x-tileXMin)/tileXInterval+0.5);
                  if(x_int<0) x_int=0; else if(x_int>=field->getNumColumns()) x_int=field->getNumColumns()-1;
                  int y_int = floor((y-tileYMin)/tileYInterval+0.5);
                  if(y_int<0) y_int=0; else if(y_int>=field->getNumRows()) y_int=field->getNumRows()-1;
                  double z = field->getHeight(x_int,y_int);
                  std::cout << "int x: " << x_int << ", x: " << x-tileXMin << ", y: " << y_int << ", y: " << y-tileYMin << std::endl;

                  //osg::Vec3 treePos(x,y,z);
                  osg::Vec3 treePos(x,y,z);
                  treeTrans->setPosition(treePos);
                  int treeIt = (int)floor(mt()*(double)treeNodeVector.size());
                  treeTrans->addChild(treeNodeVector[treeIt].get());
                  treeTrans->setName("TreeTransform");
               //}
            }
         }
      }
   }
#endif

#if 0
   typedef gaalet::algebra< gaalet::signature<3,0> > em;
   typedef em::mv<1, 2, 4>::type Vector;
   typedef em::mv<3, 5, 6>::type Bivector;
   typedef em::mv<0, 3, 5, 6>::type Rotor;
开发者ID:nixz,项目名称:covise,代码行数:67,代码来源:LevelTerrainCallback.cpp

示例13: featuredetect

void DrawShape::featuredetect(int XPoint,int YPoint)
{
	if(!sfile.empty() && XPoint>=(x_pos_shift-increase_width/2)*6.40 && XPoint<=(x_pos_shift-increase_width/2)*6.40+(100+increase_width)*6.4 && YPoint>=(y_pos_shift-increase_height/2)*4.8 && YPoint<=(y_pos_shift-increase_height/2)*4.8+(100+increase_height)*4.8 )//check if point is inside the view area 
	{


		OGRDataSource       *poDS;
		string dfile = sfile  + ".shp";
		string shp = "g_4326/" + sfile + ".shp";
		poDS = OGRSFDriverRegistrar::Open(shp.c_str(), FALSE );  //comment till here
		if( poDS == NULL )
		{
			WApplication::instance()->doJavaScript("alert('Open failed')");
			cout << "Open failed";
		}
		OGRLayer  *poLayer;
		poLayer = poDS->GetLayerByName( sfile.c_str() ); // comment here 
		OGRFeature *poFeature;
		OGREnvelope *   	 psExtent = new OGREnvelope();
		poLayer->GetExtent(psExtent);

		double xMin = psExtent->MinX;
		double yMin = psExtent->MinY;
		double xMax = psExtent->MaxX;
		double yMax = psExtent->MaxY;

		stringstream strm;
		strm << xMin;
		string exp;
		double scaleFactor;
		string bound_string = strm.str();
		int size = bound_string.size();
		size_t found=bound_string.find("+");
		if (found!=string::npos) {
			exp =  bound_string.substr(found+1,size);     
		}

		if(exp.empty()) {

			stringstream strExtent;
			strExtent << yMin;
			bound_string = strExtent.str();
			size = bound_string.size();
			found = bound_string.find("+");
			if(found!=string::npos) {
				exp = bound_string.substr(found+1,size); 
			}
		}
		if(exp.empty()) {
			stringstream strExtent;
			strExtent << xMax;
			bound_string = strExtent.str();
			size = bound_string.size();
			found = bound_string.find("+");
			if(found!=string::npos) {
				exp = bound_string.substr(found+1,size); 
			}
		}
		if(exp.empty()) {
			stringstream strExtent;
			strExtent << yMax;
			bound_string = strExtent.str();
			size = bound_string.size();
			found = bound_string.find("+");
			if(found!=string::npos) {
				exp = bound_string.substr(found+1,size); 
			}
		}
		if(!exp.empty()) {
			int exponent  = boost::lexical_cast<int>(exp);

			exponent-=3;
			scaleFactor = pow (10,exponent);
		}
		else
		{
			scaleFactor = 1;
		}

		xMin/=scaleFactor;
		xMax/=scaleFactor;
		yMin/=scaleFactor;
		yMax/=scaleFactor;

		double gWidth = xMax - xMin;
		double gHeight = yMax - yMin;
		double widthFactor = 1;
		double pwidth = abs(gWidth-gHeight);
		double s = gWidth - gHeight;
		if(s<0.16)
			gWidth = gHeight + 0.16;

		double scaledX=(XPoint*(gWidth* widthFactor*(100-increase_width)/100)/640 + (xMin+(-x_pos_shift+increase_width/2)/100*gWidth* widthFactor))*scaleFactor;
		double scaledY=(YPoint*(gHeight*widthFactor*(-1+increase_height/100))/480 + (yMax+(y_pos_shift-increase_height/2)/100*gHeight*widthFactor))*scaleFactor;
		OGRPoint *poPoint =new OGRPoint();
		poPoint->setX(scaledX);
		poPoint->setY(scaledY);


		poLayer->ResetReading();
//.........这里部分代码省略.........
开发者ID:LSI-IIIT,项目名称:lsiviewer,代码行数:101,代码来源:drawshape.cpp

示例14: if


//.........这里部分代码省略.........
        }
        break;

      case DGNST_ARC:
      {
          OGRLineString *poLine = new OGRLineString();
          DGNElemArc    *psArc = (DGNElemArc *) psElement;
          DGNPoint      asPoints[90];
          int           nPoints;

          nPoints = (int) (MAX(1,ABS(psArc->sweepang) / 5) + 1);
          DGNStrokeArc( hDGN, psArc, nPoints, asPoints );

          poLine->setNumPoints( nPoints );
          for( int i = 0; i < nPoints; i++ )
          {
              poLine->setPoint( i, 
                                asPoints[i].x,
                                asPoints[i].y,
                                asPoints[i].z );
          }

          poFeature->SetGeometryDirectly( poLine );
          poFeature->SetStyleString( szPen );
      }
      break;

      case DGNST_TEXT:
      {
          OGRPoint      *poPoint = new OGRPoint();
          DGNElemText   *psText = (DGNElemText *) psElement;
          char          *pszOgrFS;

          poPoint->setX( psText->origin.x );
          poPoint->setY( psText->origin.y );
          poPoint->setZ( psText->origin.z );

          poFeature->SetGeometryDirectly( poPoint );

          pszOgrFS = (char *) CPLMalloc(strlen(psText->string) + 150);

          // setup the basic label.
          sprintf( pszOgrFS, "LABEL(t:\"%s\"",  psText->string );

          // set the color if we have it. 
          if( strlen(szFSColor) > 0 )
              sprintf( pszOgrFS+strlen(pszOgrFS), ",%s", szFSColor );

          // Add the size info in ground units.
          if( ABS(psText->height_mult) >= 6.0 )
              sprintf( pszOgrFS+strlen(pszOgrFS), ",s:%dg", 
                       (int) psText->height_mult );
          else if( ABS(psText->height_mult) > 0.1 )
              sprintf( pszOgrFS+strlen(pszOgrFS), ",s:%.3fg", 
                       psText->height_mult );
          else
              sprintf( pszOgrFS+strlen(pszOgrFS), ",s:%.12fg", 
                       psText->height_mult );

          // Add the font name. Name it MstnFont<FONTNUMBER> if not available
          // in the font list. #3392
          static const char *papszFontList[] =
          { "STANDARD", "WORKING", "FANCY", "ENGINEERING", "NEWZERO", "STENCEL", //0-5
            "USTN_FANCY", "COMPRESSED", "STENCEQ", NULL, "hand", "ARCH", //6-11
            "ARCHB", NULL, NULL, "IGES1001", "IGES1002", "IGES1003", //12-17
            "CENTB", "MICROS", NULL, NULL, "ISOFRACTIONS", "ITALICS", //18-23
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:67,代码来源:ogrdgnlayer.cpp

示例15: _Write_Geometry

//---------------------------------------------------------
bool COGR_DataSource::_Write_Geometry(CSG_Shape *pShape, OGRFeature *pFeature)
{
	if( pShape && pFeature )
	{
		int					iPoint, iPart;
		TSG_Point			sgPoint;
		OGRPoint			Point;
		OGRMultiPoint		Points;
		OGRLineString		Line;
		OGRMultiLineString	Lines;
		OGRLinearRing		Ring;
		OGRPolygon			Polygon;

		switch( pShape->Get_Type() )
		{
		//-------------------------------------------------
		case SHAPE_TYPE_Point:
			sgPoint	= pShape->Get_Point(0);
			Point.setX(sgPoint.x);
			Point.setY(sgPoint.y);

			return( pFeature->SetGeometry(&Point) == OGRERR_NONE );

		//-------------------------------------------------
		case SHAPE_TYPE_Points:
			for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
			{
				for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
				{
					sgPoint	= pShape->Get_Point(iPoint, iPart);
					Point.setX(sgPoint.x);
					Point.setY(sgPoint.y);

					Points.addGeometry(&Point);
				}
			}

			return( pFeature->SetGeometry(&Points) == OGRERR_NONE );

		//-------------------------------------------------
		case SHAPE_TYPE_Line:
			if( pShape->Get_Part_Count() == 1 )
			{
				_Write_Line(pShape, &Line, 0);

				return( pFeature->SetGeometry(&Line) == OGRERR_NONE );
			}
			else
			{
				for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
				{
					if( _Write_Line(pShape, &Line, iPart) )
					{
						Lines.addGeometry(&Line);
					}
				}

				return( pFeature->SetGeometry(&Lines) == OGRERR_NONE );
			}

		//-------------------------------------------------
		case SHAPE_TYPE_Polygon:
			for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
			{
				if( _Write_Line(pShape, &Ring, iPart) )
				{
					Polygon.addRing(&Ring);
				}
			}

			return( pFeature->SetGeometry(&Polygon) == OGRERR_NONE );

		//-------------------------------------------------
		default:
			break;
		}
	}

	return( false );
}
开发者ID:am2222,项目名称:SAGA-GIS,代码行数:81,代码来源:ogr_driver.cpp


注:本文中的OGRPoint::setX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。