本文整理汇总了C++中CoordinateSequence类的典型用法代码示例。如果您正苦于以下问题:C++ CoordinateSequence类的具体用法?C++ CoordinateSequence怎么用?C++ CoordinateSequence使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CoordinateSequence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DefaultCoordinateSequence
/**
* Create a new "split edge" with the section of points between
* (and including) the two intersections.
* The label for the new edge is the same as the label for the parent edge.
*/
SegmentString*
SegmentNodeList::createSplitEdge(SegmentNode *ei0, SegmentNode *ei1)
{
//Debug.print("\ncreateSplitEdge"); Debug.print(ei0); Debug.print(ei1);
int npts = ei1->segmentIndex - ei0->segmentIndex + 2;
Coordinate lastSegStartPt=edge->getCoordinate(ei1->segmentIndex);
// if the last intersection point is not equal to the its segment start pt,
// add it to the points list as well.
// (This check is needed because the distance metric is not totally reliable!)
// The check for point equality is 2D only - Z values are ignored
bool useIntPt1=ei1->dist > 0.0 || ! ei1->coord->equals2D(lastSegStartPt);
if (! useIntPt1) {
npts--;
}
CoordinateSequence *pts = new DefaultCoordinateSequence(npts);
int ipt = 0;
//pts->setAt(Coordinate(*(ei0->coord)),ipt++);
pts->setAt(*(ei0->coord), ipt++);
for (int i = ei0->segmentIndex + 1; i <= ei1->segmentIndex; i++) {
pts->setAt(edge->getCoordinate(i),ipt++);
}
if (useIntPt1) pts->setAt(*(ei1->coord),ipt++);
SegmentString *ret = new SegmentString(pts,edge->getContext());
splitEdges.push_back(ret);
splitCoordLists.push_back(pts);
return ret;
}
示例2: buf
/*static*/
string
WKTWriter::toLineString(const CoordinateSequence& seq)
{
stringstream buf("LINESTRING ", ios_base::in|ios_base::out);
unsigned int npts = seq.getSize();
if ( npts == 0 )
{
buf << "EMPTY";
}
else
{
buf << "(";
for (unsigned int i=0; i<npts; ++i)
{
if (i) buf << ", ";
buf << seq.getX(i) << " " << seq.getY(i);
#if PRINT_Z
buf << seq.getZ(i);
#endif
}
buf << ")";
}
return buf.str();
}
示例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;
}
示例4: create
shared_ptr<LineString> ElementConverter::convertToLineString(const ConstWayPtr& w) const
{
const std::vector<long>& ids = w->getNodeIds();
int size = ids.size();
if (size == 1)
{
size = 2;
}
CoordinateSequence* cs = GeometryFactory::getDefaultInstance()->getCoordinateSequenceFactory()->
create(size, 2);
for (size_t i = 0; i < ids.size(); i++)
{
shared_ptr<const Node> n = _constProvider->getNode(ids[i]);
cs->setAt(n->toCoordinate(), i);
}
// a linestring cannot contain 1 point. Do this to keep it valid.
if (ids.size() == 1)
{
shared_ptr<const Node> n = _constProvider->getNode(ids[0]);
cs->setAt(n->toCoordinate(), 1);
}
shared_ptr<LineString> result(GeometryFactory::getDefaultInstance()->createLineString(cs));
return result;
}
示例5: 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;
}
示例6: testInvariant
Edge*
Edge::getCollapsedEdge()
{
testInvariant();
CoordinateSequence *newPts = new CoordinateArraySequence(2);
newPts->setAt(pts->getAt(0),0);
newPts->setAt(pts->getAt(1),1);
return new Edge(newPts, Label::toLineLabel(label));
}
示例7:
void
DelaunayTriangulationBuilder::unique(CoordinateSequence& coords)
{
std::vector<Coordinate> coordVector;
coords.toVector(coordVector);
std::sort(coordVector.begin(), coordVector.end(), geos::geom::CoordinateLessThen());
coords.setPoints(coordVector);
coords.removeRepeatedPoints();
}
示例8: CoordinateSequence
CoordinateArraySequence::CoordinateArraySequence(
const CoordinateSequence &c )
:
CoordinateSequence(c),
vect(new vector<Coordinate>(c.size())),
dimension(c.getDimension())
{
for (size_t i = 0, n = vect->size(); i < n; ++i) {
(*vect)[i] = c.getAt(i);
}
}
示例9:
void
WKBWriter::writeCoordinateSequence(const CoordinateSequence &cs,
bool sized)
{
int size = cs.getSize();
bool is3d=false;
if ( cs.getDimension() > 2 && outputDimension > 2) is3d = true;
if (sized) writeInt(size);
for (int i=0; i<size; i++) writeCoordinate(cs, i, is3d);
}
示例10:
CoordinateSequence *
WKBReader::readCoordinateSequence(int size)
{
CoordinateSequence *seq = factory.getCoordinateSequenceFactory()->create(size, inputDimension);
unsigned int targetDim = seq->getDimension();
if ( targetDim > inputDimension )
targetDim = inputDimension;
for (int i=0; i<size; i++) {
readCoordinate();
for (unsigned int j=0; j<targetDim; j++) {
seq->setOrdinate(i, j, ordValues[j]);
}
}
return seq;
}
示例11: assert
/*private*/
SegmentString*
SegmentNodeList::createSplitEdge(SegmentNode *ei0, SegmentNode *ei1)
{
assert(ei0);
assert(ei1);
size_t npts = ei1->segmentIndex - ei0->segmentIndex + 2;
const Coordinate &lastSegStartPt=edge.getCoordinate(ei1->segmentIndex);
// if the last intersection point is not equal to the its
// segment start pt, add it to the points list as well.
// (This check is needed because the distance metric is not
// totally reliable!)
// The check for point equality is 2D only - Z values are ignored
// Added check for npts being == 2 as in that case NOT using second point
// would mean creating a SegmentString with a single point
// FIXME: check with mbdavis about this, ie: is it a bug in the caller ?
//
bool useIntPt1 = npts == 2 || (ei1->isInterior() || ! ei1->coord.equals2D(lastSegStartPt));
if (! useIntPt1) {
npts--;
}
CoordinateSequence *pts = new CoordinateArraySequence(npts);
size_t ipt = 0;
pts->setAt(ei0->coord, ipt++);
for (size_t i=ei0->segmentIndex+1; i<=ei1->segmentIndex; i++)
{
pts->setAt(edge.getCoordinate(i),ipt++);
}
if (useIntPt1) pts->setAt(ei1->coord, ipt++);
SegmentString *ret = new SegmentString(pts, edge.getData());
#if GEOS_DEBUG
std::cerr<<" SegmentString created"<<std::endl;
#endif
splitEdges.push_back(ret);
// Keep track of created CoordinateSequence to release
// it at this SegmentNodeList destruction time
splitCoordLists.push_back(pts);
return ret;
}
示例12: point
Coordinate WayAverager::_moveToLineAsCoordinate(long ni, double nWeight, const LineString* ls,
double lWeight)
{
shared_ptr<Node> n = _map.getNode(ni);
Point* point(GeometryFactory::getDefaultInstance()->createPoint(n->toCoordinate()));
// find the two closest points
CoordinateSequence* cs = DistanceOp::closestPoints(point, const_cast<LineString*>(ls));
Coordinate result = Coordinate(cs->getAt(0).x * nWeight + cs->getAt(1).x * lWeight,
cs->getAt(0).y * nWeight + cs->getAt(1).y * lWeight);
delete cs;
delete point;
return result;
}
示例13: addTriangle
/* private */
void
Centroid::addHole(const CoordinateSequence& pts)
{
bool isPositiveArea = CGAlgorithms::isCCW(&pts);
for (size_t i = 0, e = pts.size() - 1; i < e; ++i) {
addTriangle(*areaBasePt, pts[i], pts[i+1], isPositiveArea);
}
addLineSegments(pts);
}
示例14: p
Coordinate BaseComparator::_findNearestPointOnFeature(shared_ptr<OsmMap> map, Coordinate c)
{
Coordinate result;
// find the nearest feature
long wId = map->getIndex().findNearestWay(c);
shared_ptr<Way> w = map->getWay(wId);
// find the nearest point on that feature.
shared_ptr<Point> p(GeometryFactory::getDefaultInstance()->createPoint(c));
shared_ptr<LineString> ls = ElementConverter(map).convertToLineString(w);
CoordinateSequence* cs = DistanceOp::closestPoints(p.get(), ls.get());
cs->getAt(0, result);
delete cs;
return result;
}
示例15: throw
/* private */
void
BufferBuilder::computeNodedEdges(SegmentString::NonConstVect& bufferSegStrList,
const PrecisionModel *precisionModel) // throw(GEOSException)
{
Noder* noder = getNoder( precisionModel );
noder->computeNodes(&bufferSegStrList);
SegmentString::NonConstVect* nodedSegStrings = \
noder->getNodedSubstrings();
for (SegmentString::NonConstVect::iterator
i=nodedSegStrings->begin(), e=nodedSegStrings->end();
i!=e;
++i)
{
SegmentString* segStr = *i;
const Label* oldLabel = static_cast<const Label*>(segStr->getData());
CoordinateSequence* cs = CoordinateSequence::removeRepeatedPoints(segStr->getCoordinates());
if ( cs->size() < 2 )
{
delete cs; // we need to take care of the memory here as cs is a new sequence
return; // don't insert collapsed edges
}
// we need to clone SegmentString coordinates
// as Edge will take ownership of them
// TODO: find a way to transfer ownership instead
// Who will own the edge ? FIXME: find out and handle that!
Edge* edge = new Edge(cs, new Label(*oldLabel));
// will take care of the Edge ownership
insertUniqueEdge(edge);
}
if ( nodedSegStrings != &bufferSegStrList )
{
delete nodedSegStrings;
}
if ( noder != workingNoder ) delete noder;
}