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


C++ LineString类代码示例

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


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

示例1: visit

void ForceValidityVisitor::visit( LineString& g )
{
    g.forceValidityFlag( valid_ );
    for ( size_t i = 0; i < g.numPoints(); i++ ) {
        visit( g.pointN( i ) );
    }
}
开发者ID:Ezio47,项目名称:SFCGAL,代码行数:7,代码来源:ForceValidityVisitor.cpp

示例2: geosIntersect

  bool geosIntersect(const LineSegment& ls1, Meters buffer, const LineSegment& ls2,
                     LineSegment& result)
  {
    boost::shared_ptr<Geometry> g1(ls1.toGeometry(*GeometryFactory::getDefaultInstance())->clone());
    boost::shared_ptr<Geometry> g2(ls2.toGeometry(*GeometryFactory::getDefaultInstance())->clone());
    boost::shared_ptr<Geometry> g(g1->buffer(buffer, 40));

    boost::shared_ptr<Geometry> i(g->intersection(g2.get()));

    if (i->isEmpty())
    {
      result.p0 = Coordinate::getNull();
      return false;
    }
    else if (i->getGeometryTypeId() == GEOS_POINT)
    {
      Point* p = dynamic_cast<Point*>(i.get());
      result.p0 = *(p->getCoordinate());
    }
    else if (i->getGeometryTypeId() == GEOS_LINESTRING)
    {
      LineString* ls = dynamic_cast<LineString*>(i.get());
      assert(ls->getNumPoints() == 2);
      result.p0 = *ls->getPointN(0)->getCoordinate();
      result.p1 = *ls->getPointN(1)->getCoordinate();
    }
    else
    {
      throw HootException();
    }
    return true;
  }
开发者ID:ngageoint,项目名称:hootenanny,代码行数:32,代码来源:BufferedLineSegmentIntersectorTest.cpp

示例3:

bool
SegmentIntersectionTester::hasIntersection(
	const LineString &line, const LineString &testLine)
{
  typedef std::size_t size_type;

	const CoordinateSequence &seq0 = *(line.getCoordinatesRO());
  size_type seq0size = seq0.getSize();

  const CoordinateSequence &seq1 = *(testLine.getCoordinatesRO());
  size_type seq1size = seq1.getSize();

  for (size_type i = 1; i<seq0size && !hasIntersectionVar; ++i)
	{
    seq0.getAt(i - 1, pt00);
    seq0.getAt(i, pt01);

    for (size_type j = 1; j < seq1size && !hasIntersectionVar; ++j)
		{
      seq1.getAt(j-1, pt10);
      seq1.getAt(j, pt11);

			li.computeIntersection(pt00, pt01, pt10, pt11);
			if (li.hasIntersection()) hasIntersectionVar = true;
		}
	}

	return hasIntersectionVar;
}
开发者ID:mwtoews,项目名称:libgeos,代码行数:29,代码来源:SegmentIntersectionTester.cpp

示例4: minkowskiSum

void minkowskiSum( const LineString& gA, const Polygon_2& gB, Polygon_set_2& polygonSet )
{
    if ( gA.isEmpty() ) {
        return ;
    }

    int npt = gA.numPoints() ;

    for ( int i = 0; i < npt - 1 ; i++ ) {
        Polygon_2 P;
        P.push_back( gA.pointN( i ).toPoint_2() );
        P.push_back( gA.pointN( i+1 ).toPoint_2() );

        //
        // We want to compute the "minkowski sum" on each segment of the line string
        // This is not very well defined. But it appears CGAL supports it.
        // However we must use the explicit "full convolution" method for that particular case in CGAL >= 4.7
#if CGAL_VERSION_NR < 1040701000 // version 4.7
        Polygon_with_holes_2 part = minkowski_sum_2( P, gB );
#else
        Polygon_with_holes_2 part = minkowski_sum_by_full_convolution_2( P, gB );
#endif

        // merge into a polygon set
        if ( polygonSet.is_empty() ) {
            polygonSet.insert( part );
        }
        else {
            polygonSet.join( part );
        }
    }
}
开发者ID:hdeeken,项目名称:SFCGAL,代码行数:32,代码来源:minkowskiSum.cpp

示例5: compute

      void compute()
      {
          //Tell the calculator about the new start/end points
          _profileCalculator->setStartEnd( GeoPoint(_mapNode->getMapSRS(), _start.x(), _start.y(), 0),
                                           GeoPoint(_mapNode->getMapSRS(), _end.x(), _end.y(), 0));

          if (_featureNode.valid())
          {
              _root->removeChild( _featureNode.get() );
              _featureNode = 0;
          }

          LineString* line = new LineString();
          line->push_back( _start );
          line->push_back( _end );
          Feature* feature = new Feature(line, _mapNode->getMapSRS());
          feature->geoInterp() = GEOINTERP_GREAT_CIRCLE;    

          //Define a style for the line
          Style style;
          LineSymbol* ls = style.getOrCreateSymbol<LineSymbol>();
          ls->stroke()->color() = Color::Yellow;
          ls->stroke()->width() = 2.0f;
          ls->tessellation() = 20;

          style.getOrCreate<AltitudeSymbol>()->clamping() = AltitudeSymbol::CLAMP_TO_TERRAIN;

          feature->style() = style;

          _featureNode = new FeatureNode( _mapNode, feature );
          //Disable lighting
          _featureNode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
          _root->addChild( _featureNode.get() );

      }
开发者ID:airwzz999,项目名称:osgearth-for-android,代码行数:35,代码来源:osgearth_terrainprofile.cpp

示例6: TEST

TEST(TileCover, DISABLED_FuzzLine) {
    while(1)
    {
        std::srand (time(NULL));
        std::size_t len = std::rand() % 10000 + 3;
        MultiLineString<double> mls;

        std::size_t num_lines = 1;
        num_lines += std::rand() % 5;
        while (num_lines > 0) {
            LineString<double> line;
            for (std::size_t i = 0; i < len; ++i) {
                double x = std::rand() % 180;
                double y = std::rand() % 90;

                line.push_back({x,y});
            }
            mls.emplace_back(line);
            --num_lines;
        }
        
        std::clog << ".";
        util::TileCover tc(mls, 5);
        while(tc.next()) {
        };
    }
}
开发者ID:BharathMG,项目名称:mapbox-gl-native,代码行数:27,代码来源:tile_cover.test.cpp

示例7: Geometry

LineString::LineString( const LineString& other ):
    Geometry()
{
    for ( size_t i = 0; i < other.numPoints(); i++ ) {
        _points.push_back( other.pointN( i ).clone() ) ;
    }
}
开发者ID:hjanetzek,项目名称:SFCGAL,代码行数:7,代码来源:LineString.cpp

示例8:

Handle<Value> LineStringPoints::count(const Arguments& args)
{
	HandleScope scope;

	Handle<Object> parent = args.This()->GetHiddenValue(String::NewSymbol("parent_"))->ToObject();
	LineString *geom = ObjectWrap::Unwrap<LineString>(parent);

	return scope.Close(Integer::New(geom->get()->getNumPoints()));
}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:9,代码来源:linestring_points.cpp

示例9: writeInner

void WktWriter::writeInner( const LineString & g )
{
	_s << "(";
	for ( size_t i = 0; i < g.numPoints(); i++ ){
		if ( i != 0 )
			_s << ",";

		write( g.pointN(i).coordinates() );
	}
	_s << ")";
}
开发者ID:mborne,项目名称:sfcgal-with-postgis,代码行数:11,代码来源:WktWriter.cpp

示例10: Undefined

Handle<Value> LineStringPoints::reverse(const Arguments& args)
{
	HandleScope scope;

	Handle<Object> parent = args.This()->GetHiddenValue(String::NewSymbol("parent_"))->ToObject();
	LineString *geom = ObjectWrap::Unwrap<LineString>(parent);

	geom->get()->reversePoints();

	return Undefined();
}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:11,代码来源:linestring_points.cpp

示例11: LineString

Geometry*
Ring::cloneAs( const Geometry::Type& newType ) const
{
    if ( newType == TYPE_LINESTRING )
    {
        LineString* line = new LineString( &this->asVector() );
        if ( line->size() > 1 && line->front() != line->back() )
            line->push_back( front() );
        return line;
    }
    else return Geometry::cloneAs( newType );
}
开发者ID:3dcl,项目名称:osgearth,代码行数:12,代码来源:Geometry.cpp

示例12: writeByteOrder

void
WKBWriter::writeLineString(const LineString& g)
{
    writeByteOrder();

    writeGeometryType(WKBConstants::wkbLineString, g.getSRID());
    writeSRID(g.getSRID());

    const CoordinateSequence* cs = g.getCoordinatesRO();
    assert(cs);
    writeCoordinateSequence(*cs, true);
}
开发者ID:libgeos,项目名称:libgeos,代码行数:12,代码来源:WKBWriter.cpp

示例13: isClosed

bool MultiLineString::isClosed() const {
	if (isEmpty()) {
		return false;
	}
	for (size_t i = 0, n = geometries->size(); i < n; ++i) {
		LineString *ls = dynamic_cast<LineString*>((*geometries)[i]);
		if ( ! ls->isClosed() ) {
			return false;
		}
	}
	return true;
}
开发者ID:AvlWx2014,项目名称:basemap,代码行数:12,代码来源:MultiLineString.cpp

示例14:

std::unordered_map<std::string, std::vector<Feature>> Source::Impl::queryRenderedFeatures(const QueryParameters& parameters) const {
    std::unordered_map<std::string, std::vector<Feature>> result;
    if (renderTiles.empty() || parameters.geometry.empty()) {
        return result;
    }

    LineString<double> queryGeometry;

    for (const auto& p : parameters.geometry) {
        queryGeometry.push_back(TileCoordinate::fromScreenCoordinate(
            parameters.transformState, 0, { p.x, parameters.transformState.getSize().height - p.y }).p);
    }

    mapbox::geometry::box<double> box = mapbox::geometry::envelope(queryGeometry);


    auto sortRenderTiles = [](const RenderTile& a, const RenderTile& b) {
        return a.id.canonical.z != b.id.canonical.z ? a.id.canonical.z < b.id.canonical.z :
               a.id.canonical.y != b.id.canonical.y ? a.id.canonical.y < b.id.canonical.y :
               a.id.wrap != b.id.wrap ? a.id.wrap < b.id.wrap : a.id.canonical.x < b.id.canonical.x;
    };
    std::vector<std::reference_wrapper<const RenderTile>> sortedTiles;
    std::transform(renderTiles.cbegin(), renderTiles.cend(), std::back_inserter(sortedTiles),
                   [](const auto& pair) { return std::ref(pair.second); });
    std::sort(sortedTiles.begin(), sortedTiles.end(), sortRenderTiles);

    for (const auto& renderTileRef : sortedTiles) {
        const RenderTile& renderTile = renderTileRef.get();
        GeometryCoordinate tileSpaceBoundsMin = TileCoordinate::toGeometryCoordinate(renderTile.id, box.min);
        if (tileSpaceBoundsMin.x >= util::EXTENT || tileSpaceBoundsMin.y >= util::EXTENT) {
            continue;
        }

        GeometryCoordinate tileSpaceBoundsMax = TileCoordinate::toGeometryCoordinate(renderTile.id, box.max);
        if (tileSpaceBoundsMax.x < 0 || tileSpaceBoundsMax.y < 0) {
            continue;
        }

        GeometryCoordinates tileSpaceQueryGeometry;
        tileSpaceQueryGeometry.reserve(queryGeometry.size());
        for (const auto& c : queryGeometry) {
            tileSpaceQueryGeometry.push_back(TileCoordinate::toGeometryCoordinate(renderTile.id, c));
        }

        renderTile.tile.queryRenderedFeatures(result,
                                              tileSpaceQueryGeometry,
                                              parameters.transformState,
                                              parameters.layerIDs);
    }

    return result;
}
开发者ID:Mappy,项目名称:mapbox-gl-native,代码行数:52,代码来源:source_impl.cpp

示例15: assert

MultiLineString*
MultiLineString::reverse() const
{
	size_t nLines = geometries->size();
	Geometry::NonConstVect *revLines = new Geometry::NonConstVect(nLines);
	for (size_t i=0; i<nLines; ++i)
	{
		LineString *iLS = dynamic_cast<LineString*>((*geometries)[i]);
		assert(iLS);
		(*revLines)[nLines-1-i] = iLS->reverse();
	}
	return getFactory()->createMultiLineString(revLines);
}
开发者ID:AvlWx2014,项目名称:basemap,代码行数:13,代码来源:MultiLineString.cpp


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