本文整理汇总了C++中CoordinateSequence::setAt方法的典型用法代码示例。如果您正苦于以下问题:C++ CoordinateSequence::setAt方法的具体用法?C++ CoordinateSequence::setAt怎么用?C++ CoordinateSequence::setAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoordinateSequence
的用法示例。
在下文中一共展示了CoordinateSequence::setAt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: CoordinateArraySequence
/*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;
}
示例4: Edge
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));
}