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


C++ CoordinateSequence::add方法代码示例

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


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

示例1: catch

CoordinateSequence*
WKTReader::getCoordinates(StringTokenizer *tokenizer)
{
	string nextToken=getNextEmptyOrOpener(tokenizer);
	if (nextToken=="EMPTY") {
		return geometryFactory->getCoordinateSequenceFactory()->create(NULL);
		//new CoordinateArraySequence(); 
	}
	CoordinateSequence *coordinates = \
		geometryFactory->getCoordinateSequenceFactory()->create(NULL);
	Coordinate coord;
	getPreciseCoordinate(tokenizer, coord);
	coordinates->add(coord);
	try {
		nextToken=getNextCloserOrComma(tokenizer);
		while (nextToken==",") {
			getPreciseCoordinate(tokenizer, coord);
			coordinates->add(coord);
			nextToken=getNextCloserOrComma(tokenizer);
		}
	} catch (...) {
		delete coordinates;
		throw;
	}
	return coordinates;
}
开发者ID:asapnet,项目名称:geos,代码行数:26,代码来源:WKTReader.cpp

示例2: coordinateSeq3

void coordinateSeq3() {
    CoordinateSequence *cl = new CoordinateArraySequence();
    cl->add(Coordinate(116.5189446,39.9385391));
    cl->add(Coordinate(116.5389472,39.9386038));
    cl->add(Coordinate(116.5589889,39.9387932));
    cl->add(Coordinate(116.5789501,39.9386662));

    cl->add(Coordinate(116.5889538,39.9387273));

    cl->add(Coordinate(116.5289589,39.2387832));
    cl->add(Coordinate(116.548965,39.9388347));
    cl->add(Coordinate(116.5689136,39.9385191));
    cl->add(Coordinate(116.5089711,39.9388873));
    cl->add(Coordinate(116.5459744,39.9389397));
    cl->add(Coordinate(116.5819436,39.9385291));
    MultiPoint *mp = global_factory->createMultiPoint(*cl);

    prep::PreparedGeometry const *pg_ = prep::PreparedGeometryFactory::prepare(mp);
    pg_->getGeometry();

    CoordinateSequence *cr = new CoordinateArraySequence();
    cr->add(Coordinate(116.5889539 + 0.000005, 39.9387274 + 0.000005));
    cr->add(Coordinate(116.5889539 + 0.000005, 39.9387274 - 0.000005));
    cr->add(Coordinate(116.5889539 - 0.000005, 39.9387274 - 0.000005));
    cr->add(Coordinate(116.5889539 - 0.000005, 39.9387274 + 0.000005));
    cr->add(Coordinate(116.5889539 + 0.000005, 39.9387274 + 0.000005));
    MultiPoint *mp2 = global_factory->createMultiPoint(*cr);


    LinearRing *li = global_factory->createLinearRing(cr);
    geos::geom::Polygon *poly1=global_factory->createPolygon(li,NULL);

    //geos::geom::Geometry *pint = mp2->intersection(mp);
    //geos::geom::Geometry *pint = mp2->intersection(poly1);
    geos::geom::Geometry *pint = pg_->getGeometry().intersection(poly1);

    //CoordinateSequence *coord = pint->getCoordinates();	
    CoordinateSequence *coord = pg_->getGeometry().getCoordinates();	

    printf("getNumPoints: %lu\n", pint->getNumPoints());
    printf("Get CoordinateSequence Num: %lu\n", coord->getSize());

    for (int i=0; i<coord->getSize(); i++) {
        printf("Get CoordinateSequence [%d]-(%f, %f)\n", i, coord->getX(i), coord->getY(i));
    }
    delete coord;
    delete pint;
    delete mp;
    delete mp2;
    delete cl;
    delete cr;
}
开发者ID:border,项目名称:notes,代码行数:52,代码来源:example.cpp

示例3: coordinateSeq

void coordinateSeq() {
    CoordinateSequence *cl = new CoordinateArraySequence();
    cl->add(Coordinate(100,100));
    cl->add(Coordinate(100,200));
    cl->add(Coordinate(200,200));
    cl->add(Coordinate(200,100));
    cl->add(Coordinate(180,180));
    //cl->add(Coordinate(100,100));
    cl->add(geos::geom::Coordinate(150, 150));
    cl->add(geos::geom::Coordinate(190, 190));
    cl->add(geos::geom::Coordinate(150, 250));
    cl->add(geos::geom::Coordinate(250, 250));
    cl->add(geos::geom::Coordinate(250, 150));
    //cl->add(geos::geom::Coordinate(150, 150));
 
    LinearRing *lr = global_factory->createLinearRing(cl);
    geos::geom::Polygon *poly=NULL;
    poly = global_factory->createPolygon(lr,NULL);     

    CoordinateSequence *cr = new CoordinateArraySequence();
    cr->add(geos::geom::Coordinate(120, 120));
    cr->add(geos::geom::Coordinate(120, 170));
    cr->add(geos::geom::Coordinate(170, 170));
    cr->add(geos::geom::Coordinate(170, 120));
    //cr->add(geos::geom::Coordinate(120, 120));

    LinearRing *li = global_factory->createLinearRing(cr);
    geos::geom::Polygon *poly1=global_factory->createPolygon(li,NULL);

    geos::geom::Geometry *pint = poly1->intersection(poly);
	io::WKTWriter *wkt = new io::WKTWriter();
    string tmp=wkt->write(pint);
    cout<<" (WKT coordinateSeq Intersection) "<<tmp<<endl;
}
开发者ID:border,项目名称:notes,代码行数:34,代码来源:example.cpp

示例4: line

    void object::test<1>()
    {
	CoordinateSequence* cs = new CoordinateArraySequence();
	cs->add(Coordinate(0.0, 0.0));
	cs->add(Coordinate(1.0, DoubleNotANumber));
	GeomPtr line ( factory_.createLineString(cs) );


	IsValidOp isValidOp(line.get());
	bool valid = isValidOp.isValid();

	TopologyValidationError* err = isValidOp.getValidationError();
    ensure(0 != err);
    const Coordinate& errCoord = err->getCoordinate();

	ensure_equals( err->getErrorType(),
	               TopologyValidationError::eInvalidCoordinate );

	ensure(0 != ISNAN(errCoord.y));
	ensure_equals(valid, false);
    }
开发者ID:AvlWx2014,项目名称:basemap,代码行数:21,代码来源:IsValidTest.cpp

示例5: CoordinateArraySequence

// This function will create a LinearString
// geometry with the shape of the letter U
// having top-left corner at given coordinates
// and 'side' height and width 
LineString *
create_ushaped_linestring(double xoffset, double yoffset, double side)
{
	// We will use a coordinate list to build the linestring
	CoordinateSequence *cl = new CoordinateArraySequence();

	cl->add(Coordinate(xoffset, yoffset));
	cl->add(Coordinate(xoffset, yoffset+side));
	cl->add(Coordinate(xoffset+side, yoffset+side));
	cl->add(Coordinate(xoffset+side, yoffset));

	// Now that we have a CoordinateSequence we can create 
	// the linestring.
	// The newly created LineString will take ownership
	// of the CoordinateSequence.
	LineString *ls = global_factory->createLineString(cl);

	// This is what you do if you want the new LineString
	// to make a copy of your CoordinateSequence:
	// LineString *ls = global_factory->createLineString(*cl);
	
	return ls; // our LineString
}
开发者ID:h4ck3rm1k3,项目名称:geos,代码行数:27,代码来源:example.cpp

示例6: coordinateSeq2

void coordinateSeq2() {
    CoordinateSequence *cl = new CoordinateArraySequence();
    cl->add(Coordinate(100,100));
    cl->add(Coordinate(100,200));
    cl->add(Coordinate(200,200));
    cl->add(Coordinate(200,100));
    cl->add(Coordinate(180,180));
    cl->add(Coordinate(100,100));
    LinearRing *lr = global_factory->createLinearRing(cl);
    geos::geom::Polygon *poly=NULL;
    poly = global_factory->createPolygon(lr,NULL);     

    CoordinateSequence *cr = new CoordinateArraySequence();
    cr->add(geos::geom::Coordinate(150, 150));
    cr->add(geos::geom::Coordinate(190, 190));
    cr->add(geos::geom::Coordinate(150, 250));
    cr->add(geos::geom::Coordinate(250, 250));
    cr->add(geos::geom::Coordinate(250, 150));
    cr->add(geos::geom::Coordinate(150, 150));

    //geos::geom::Polygon *poly1 = create_circle(150, 150, 10);

    LinearRing *li = global_factory->createLinearRing(cr);
    geos::geom::Polygon *poly1=global_factory->createPolygon(li,NULL);

    geos::geom::Geometry *pint = poly1->intersection(poly);
	io::WKTWriter *wkt = new io::WKTWriter();
    string tmp=wkt->write(pint);
    cout<<" (WKT coordinateSeq Intersection) "<<tmp<<endl;

    printf("getNumPoints: %lu\n", pint->getNumPoints());

	vector<Geometry *> *newgeoms = new vector<Geometry *>;
    newgeoms->push_back(pint);

	cout<<endl<<"----- HERE ARE SOME INTERSECTIONS COMBINATIONS ------"<<endl;
	wkt_print_geoms(newgeoms);

    CoordinateSequence *coord = pint->getCoordinates();	
    printf("Get CoordinateSequence Num: %lu\n", coord->getSize());

    for (int i=0; i<coord->getSize(); i++) {
        printf("Get CoordinateSequence [%d]-(%f, %f)\n", i, coord->getX(i), coord->getY(i));
    }
    delete coord;
    delete newgeoms;
}
开发者ID:border,项目名称:notes,代码行数:47,代码来源:example.cpp

示例7: q

	void object::test<13>()
	{
    Coordinate p1(-123456789, -40);
    Coordinate p2(381039468754763.0, 123456789);
    Coordinate q(0, 0);

    using geos::geom::CoordinateSequence;
    using geos::geom::GeometryFactory;
    using geos::geom::LineString;

    GeometryFactory::Ptr factory = GeometryFactory::create();
    CoordinateSequence* cs = new CoordinateArraySequence();
    cs->add(p1);
    cs->add(p2);

    GeomPtr l ( factory->createLineString(cs) );
    GeomPtr p ( factory->createPoint(q) );
    ensure(!l->intersects(p.get()));

    ensure(!CGAlgorithms::isOnLine(q, cs));
    ensure_equals(CGAlgorithms::computeOrientation(p1, p2, q), -1);

	}
开发者ID:nextgis-borsch,项目名称:lib_geos,代码行数:23,代码来源:RobustLineIntersectorTest.cpp

示例8:

void
RectangleIntersectionBuilder::reconnect()
{
  // Nothing to reconnect if there aren't at least two lines
  if(lines.size() < 2)
       return;

  geom::LineString * line1 = lines.front();
  const geom::CoordinateSequence &cs1 = *line1->getCoordinatesRO();

  geom::LineString * line2 = lines.back();
  const geom::CoordinateSequence &cs2 = *line2->getCoordinatesRO();

  const int n1 = cs1.size();
  const int n2 = cs2.size();

  // Safety check against bad input to prevent segfaults
  if(n1==0 || n2==0)
       return;

  if (cs1[0] != cs2[n2-1]) return;

  // Merge the two linestrings

  CoordinateSequence *ncs = CoordinateSequence::removeRepeatedPoints(&cs2);
  ncs->add(&cs1, false, true);

  delete line1;
  delete line2;

  LineString * nline = _gf.createLineString(ncs);
  lines.pop_front();
  lines.pop_back();

  lines.push_front(nline);
}
开发者ID:52North,项目名称:IlwisCore,代码行数:36,代码来源:RectangleIntersectionBuilder.cpp

示例9: if

MultiPoint*
WKTReader::readMultiPointText(StringTokenizer *tokenizer)
{
	string nextToken=getNextEmptyOrOpener(tokenizer);
	if (nextToken=="EMPTY") {
		return geometryFactory->createMultiPoint();
	}

	int tok = tokenizer->peekNextToken();

	if ( tok == StringTokenizer::TT_NUMBER )
	{
		// Try to parse deprecated form "MULTIPOINT(0 0, 1 1)"
		const CoordinateSequenceFactory* csf = \
			geometryFactory->getCoordinateSequenceFactory();
		CoordinateSequence *coords = csf->create(NULL);
		try {
			do {
				Coordinate coord;
				getPreciseCoordinate(tokenizer, coord);
				coords->add(coord);
				nextToken=getNextCloserOrComma(tokenizer);
			} while(nextToken == ",");

			MultiPoint *ret = geometryFactory->createMultiPoint(*coords);
			delete coords;
			return ret;
		} catch (...) {
			delete coords;
			throw;
		}
	}

	else if ( tok == '(' )
	{
		// Try to parse correct form "MULTIPOINT((0 0), (1 1))"
		vector<Geometry *> *points=new vector<Geometry *>();
		try {
			do {
				Point *point=readPointText(tokenizer);
				points->push_back(point);
				nextToken=getNextCloserOrComma(tokenizer);
			} while(nextToken == ",");
			return geometryFactory->createMultiPoint(points);
		} catch (...) {
			// clean up 
			for (size_t i=0; i<points->size(); i++)
			{
				delete (*points)[i];
			}
			delete points;
			throw;
		}
	}

	else 
	{
		stringstream err;
		err << "Unexpected token: ";
		switch (tok)
		{
			case StringTokenizer::TT_WORD:
				err << "WORD " << tokenizer->getSVal();
				break;
			case StringTokenizer::TT_NUMBER:
				err << "NUMBER " << tokenizer->getNVal();
				break;
			case StringTokenizer::TT_EOF:
			case StringTokenizer::TT_EOL:
				err << "EOF or EOL";
				break;
			case '(':
				err << "(";
				break;
			case ')':
				err << ")";
				break;
			case ',':
				err << ",";
				break;
			default:
				err << "??";
				break;
		}
		err << endl;
		throw ParseException(err.str());
		return NULL;
	}
}
开发者ID:asapnet,项目名称:geos,代码行数:89,代码来源:WKTReader.cpp


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