本文整理汇总了C++中GeoDataLineString类的典型用法代码示例。如果您正苦于以下问题:C++ GeoDataLineString类的具体用法?C++ GeoDataLineString怎么用?C++ GeoDataLineString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GeoDataLineString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toNormalized
GeoDataLineString GeoDataLineString::toNormalized() const
{
GeoDataLineString normalizedLineString;
normalizedLineString.setTessellationFlags( tessellationFlags() );
qreal lon;
qreal lat;
// FIXME: Think about how we can avoid unnecessary copies
// if the linestring stays the same.
QVector<GeoDataCoordinates>::const_iterator end = p()->m_vector.constEnd();
for( QVector<GeoDataCoordinates>::const_iterator itCoords
= p()->m_vector.constBegin();
itCoords != end;
++itCoords ) {
itCoords->geoCoordinates( lon, lat );
qreal alt = itCoords->altitude();
GeoDataCoordinates::normalizeLonLat( lon, lat );
GeoDataCoordinates normalizedCoords( *itCoords );
normalizedCoords.set( lon, lat, alt );
normalizedLineString << normalizedCoords;
}
return normalizedLineString;
}
示例2: Q_ASSERT
bool PolylineAnnotation::processAddingNodesOnMove( QMouseEvent *mouseEvent )
{
Q_ASSERT( mouseEvent->button() == Qt::NoButton );
const int index = virtualNodeContains( mouseEvent->pos() );
// If we are adjusting a virtual node which has just been clicked and became real, just
// change its coordinates when moving it, as we do with nodes in Editing state on move.
if ( m_adjustedNode != -1 ) {
// The virtual node which has just been added is always the last within
// GeoDataLinearRing's container.qreal lon, lat;
qreal lon, lat;
m_viewport->geoCoordinates( mouseEvent->pos().x(),
mouseEvent->pos().y(),
lon, lat,
GeoDataCoordinates::Radian );
const GeoDataCoordinates newCoords( lon, lat );
GeoDataLineString *line = static_cast<GeoDataLineString*>( placemark()->geometry() );
line->at(m_adjustedNode) = newCoords;
return true;
// If we are hovering a virtual node, store its index in order to be painted in drawNodes
// method.
} else if ( index != -1 ) {
m_virtualHoveredNode = index;
return true;
}
return false;
}
示例3: updateRegions
void PolylineAnnotation::updateRegions( GeoPainter *painter )
{
if ( m_busy ) {
return;
}
const GeoDataLineString line = static_cast<const GeoDataLineString>( *placemark()->geometry() );
if ( state() == SceneGraphicsItem::AddingNodes ) {
// Create and update virtual nodes lists when being in the AddingPolgonNodes state, to
// avoid overhead in other states.
m_virtualNodesList.clear();
for ( int i = 0; i < line.size() - 1; ++i ) {
const QRegion newRegion( painter->regionFromEllipse( line.at(i).interpolate( line.at(i+1), 0.5 ),
hoveredDim, hoveredDim ) );
m_virtualNodesList.append( PolylineNode( newRegion ) );
}
}
// Update the polyline region;
m_polylineRegion = painter->regionFromPolyline( line, 15 );
// Update the node lists.
for ( int i = 0; i < m_nodesList.size(); ++i ) {
const QRegion newRegion = m_nodesList.at(i).isSelected() ?
painter->regionFromEllipse( line.at(i), selectedDim, selectedDim ) :
painter->regionFromEllipse( line.at(i), regularDim, regularDim );
m_nodesList[i].setRegion( newRegion );
}
}
示例4: size
bool GeoDataLineString::operator==( const GeoDataLineString &other ) const
{
if ( !GeoDataGeometry::equals(other) ||
size() != other.size() ||
tessellate() != other.tessellate() ) {
return false;
}
const GeoDataLineStringPrivate* d = p();
const GeoDataLineStringPrivate* other_d = other.p();
QVector<GeoDataCoordinates>::const_iterator itCoords = d->m_vector.constBegin();
QVector<GeoDataCoordinates>::const_iterator otherItCoords = other_d->m_vector.constBegin();
QVector<GeoDataCoordinates>::const_iterator itEnd = d->m_vector.constEnd();
QVector<GeoDataCoordinates>::const_iterator otherItEnd = other_d->m_vector.constEnd();
for ( ; itCoords != itEnd && otherItCoords != otherItEnd; ++itCoords, ++otherItCoords ) {
if ( *itCoords != *otherItCoords ) {
return false;
}
}
Q_ASSERT ( itCoords == itEnd && otherItCoords == otherItEnd );
return true;
}
示例5: append
void OsmWayGraphicsItem::append( const GeoDataPoint& point )
{
GeoDataLineString* line = dynamic_cast<GeoDataLineString*>(m_placemark->geometry());
if( line ) {
line->append( point );
}
}
示例6: placemark
bool PolylineAnnotation::processAddingNodesOnPress( QMouseEvent *mouseEvent )
{
if ( mouseEvent->button() != Qt::LeftButton ) {
return false;
}
GeoDataLineString *line = static_cast<GeoDataLineString*>( placemark()->geometry() );
// If a virtual node has just been clicked, add it to the polyline and start 'adjusting'
// its position.
const int virtualIndex = virtualNodeContains( mouseEvent->pos() );
if ( virtualIndex != -1 && m_adjustedNode == -1 ) {
Q_ASSERT( m_virtualHoveredNode == virtualIndex );
line->insert( virtualIndex + 1, line->at( virtualIndex ).interpolate( line->at( virtualIndex + 1 ), 0.5 ) );
m_nodesList.insert( virtualIndex + 1, PolylineNode() );
m_adjustedNode = virtualIndex + 1;
m_virtualHoveredNode = -1;
return true;
}
// If a virtual node which has been previously clicked and selected to become a
// 'real node' is clicked one more time, it stops from being 'adjusted'.
const int realIndex = nodeContains( mouseEvent->pos() );
if ( realIndex != -1 && m_adjustedNode != -1 ) {
m_adjustedNode = -1;
return true;
}
return false;
}
示例7: tr
void RoutingWidget::handleSearchResult( RoutingInputWidget *widget )
{
d->setActiveInput( widget );
MarblePlacemarkModel *model = widget->searchResultModel();
if ( model->rowCount() ) {
QString const results = tr( "%n placemarks found", "", model->rowCount() );
d->m_ui.resultLabel->setText( results );
d->m_ui.resultLabel->setVisible( true );
// Make sure we have a selection
activatePlacemark( model->index( 0, 0 ) );
} else {
QString const results = tr( "No placemark found" );
d->m_ui.resultLabel->setText( "<font color=\"red\">" + results + "</font>" );
d->m_ui.resultLabel->setVisible( true );
}
GeoDataLineString placemarks;
for ( int i = 0; i < model->rowCount(); ++i ) {
QVariant data = model->index( i, 0 ).data( MarblePlacemarkModel::CoordinateRole );
if ( !data.isNull() ) {
placemarks << qVariantValue<GeoDataCoordinates>( data );
}
}
if ( placemarks.size() > 1 ) {
d->m_widget->centerOn( GeoDataLatLonBox::fromLineString( placemarks ) );
//d->m_ui.descriptionLabel->setVisible( false );
if ( MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen ) {
d->m_ui.directionsListView->setVisible( true );
}
}
}
示例8: detach
void GeoDataPlacemark::unpack( QDataStream& stream )
{
detach();
p()->m_geometry->setParent( this );
GeoDataFeature::unpack( stream );
stream >> p()->m_countrycode;
stream >> p()->m_area;
stream >> p()->m_population;
int geometryId;
stream >> geometryId;
switch( geometryId ) {
case InvalidGeometryId:
break;
case GeoDataPointId:
{
GeoDataPoint* point = new GeoDataPoint;
point->unpack( stream );
delete p()->m_geometry;
p()->m_geometry = point;
}
break;
case GeoDataLineStringId:
{
GeoDataLineString* lineString = new GeoDataLineString;
lineString->unpack( stream );
delete p()->m_geometry;
p()->m_geometry = lineString;
}
break;
case GeoDataLinearRingId:
{
GeoDataLinearRing* linearRing = new GeoDataLinearRing;
linearRing->unpack( stream );
delete p()->m_geometry;
p()->m_geometry = linearRing;
}
break;
case GeoDataPolygonId:
{
GeoDataPolygon* polygon = new GeoDataPolygon;
polygon->unpack( stream );
delete p()->m_geometry;
p()->m_geometry = polygon;
}
break;
case GeoDataMultiGeometryId:
{
GeoDataMultiGeometry* multiGeometry = new GeoDataMultiGeometry;
multiGeometry->unpack( stream );
delete p()->m_geometry;
p()->m_geometry = multiGeometry;
}
break;
case GeoDataModelId:
break;
default: break;
};
}
示例9: totalDistance
qreal totalDistance() const
{
GeoDataLineString measure;
GeoDataCoordinates sourcePosition(m_source.longitude(), m_source.latitude());
GeoDataCoordinates targetPosition(m_target.longitude(), m_target.latitude());
measure << sourcePosition << targetPosition;
return measure.length(m_planetRadius);
}
示例10: detach
void GeoDataMultiGeometry::unpack( QDataStream& stream )
{
detach();
GeoDataGeometry::unpack( stream );
int size = 0;
stream >> size;
for( int i = 0; i < size; i++ ) {
int geometryId;
stream >> geometryId;
switch( geometryId ) {
case InvalidGeometryId:
break;
case GeoDataPointId:
{
GeoDataPoint *point = new GeoDataPoint;
point->unpack( stream );
p()->m_vector.append( point );
}
break;
case GeoDataLineStringId:
{
GeoDataLineString *lineString = new GeoDataLineString;
lineString->unpack( stream );
p()->m_vector.append( lineString );
}
break;
case GeoDataLinearRingId:
{
GeoDataLinearRing *linearRing = new GeoDataLinearRing;
linearRing->unpack( stream );
p()->m_vector.append( linearRing );
}
break;
case GeoDataPolygonId:
{
GeoDataPolygon *polygon = new GeoDataPolygon;
polygon->unpack( stream );
p()->m_vector.append( polygon );
}
break;
case GeoDataMultiGeometryId:
{
GeoDataMultiGeometry *multiGeometry = new GeoDataMultiGeometry;
multiGeometry->unpack( stream );
p()->m_vector.append( multiGeometry );
}
break;
case GeoDataModelId:
break;
default:
break;
};
}
}
示例11: parseBoundingBox
void MonavMap::parseBoundingBox( const QFileInfo &file )
{
GeoDataLineString points;
bool tooLarge = false;
QFile input( file.absoluteFilePath() );
if ( input.open( QFile::ReadOnly ) ) {
GeoDataParser parser( GeoData_KML );
if ( !parser.read( &input ) ) {
mDebug() << "Could not parse file: " << parser.errorString();
return;
}
GeoDocument *doc = parser.releaseDocument();
input.close();
GeoDataDocument *document = dynamic_cast<GeoDataDocument*>( doc );
QVector<GeoDataPlacemark*> placemarks = document->placemarkList();
if ( placemarks.size() == 1 ) {
GeoDataPlacemark* placemark = placemarks.first();
m_name = placemark->name();
m_version = placemark->extendedData().value( "version" ).value().toString();
m_date = placemark->extendedData().value( "date" ).value().toString();
m_transport = placemark->extendedData().value( "transport" ).value().toString();
m_payload = placemark->extendedData().value( "payload" ).value().toString();
GeoDataMultiGeometry* geometry = dynamic_cast<GeoDataMultiGeometry*>( placemark->geometry() );
if ( geometry->size() > 1500 ) {
tooLarge = true;
}
for ( int i = 0; geometry && i < geometry->size(); ++i ) {
GeoDataLinearRing* poly = dynamic_cast<GeoDataLinearRing*>( geometry->child( i ) );
if ( poly ) {
for ( int j = 0; j < poly->size(); ++j ) {
points << poly->at( j );
}
m_tiles.push_back( *poly );
}
if ( poly->size() > 1500 ) {
tooLarge = true;
}
}
} else {
mDebug() << "File " << file.absoluteFilePath() << " does not contain one placemark, but " << placemarks.size();
}
delete doc;
}
m_boundingBox = points.latLonAltBox();
if ( tooLarge ) {
// The bounding box polygon is rather complicated, therefore not allowing a quick check
// and also occupying memory. Discard the polygon and only store the rectangular bounding
// box. Only happens for non-simplified bounding box polygons.
mDebug() << "Discarding too large bounding box poylgon for " << file.absoluteFilePath() << ". Please check for a map update.";
m_tiles.clear();
}
}
示例12: Q_UNUSED
void
AprsObject::render( GeoPainter *painter, ViewportParams *viewport,
int fadeTime, int hideTime )
{
Q_UNUSED( viewport );
if ( hideTime > 0 && m_history.last().timestamp().elapsed() > hideTime )
return;
QColor baseColor = calculatePaintColor( m_seenFrom,
m_history.last().timestamp(),
fadeTime );
if ( m_history.count() > 1 ) {
QList<GeoAprsCoordinates>::iterator spot = m_history.begin();
QList<GeoAprsCoordinates>::iterator endSpot = m_history.end();
GeoDataLineString lineString;
lineString.setTessellate( true );
lineString << *spot; // *spot exists because m_history.count() > 1
for( ++spot; spot != endSpot; ++spot ) {
if ( hideTime > 0 && ( *spot ).timestamp().elapsed() > hideTime )
break;
lineString << *spot;
// draw the new circle in whatever is appropriate for that point
const QColor penColor = calculatePaintColor( spot->seenFrom(), spot->timestamp(), fadeTime );
painter->setPen( penColor );
painter->drawRect( *spot, 5, 5 );
}
// draw the line in the base color
painter->setPen( baseColor );
painter->drawPolyline( lineString );
}
// Always draw the symbol then the text last so it's on top
if ( m_havePixmap ) {
if ( ! m_pixmap )
m_pixmap = new QPixmap ( m_pixmapFilename );
if ( m_pixmap && ! m_pixmap->isNull() )
painter->drawPixmap( m_history.last(), *m_pixmap );
else
painter->drawRect( m_history.last(), 6, 6 );
}
else
painter->drawRect( m_history.last(), 6, 6 );
painter->setPen( baseColor );
painter->drawText( m_history.last(), m_myName );
}
示例13: Q_ASSERT
int RoutingModel::rightNeighbor( const GeoDataCoordinates &position, RouteRequest const *const route ) const
{
Q_ASSERT( route && "Must not pass a null route ");
// Quick result for trivial cases
if ( route->size() < 3 ) {
return route->size() - 1;
}
// Generate an ordered list of all waypoints
GeoDataLineString points = d->m_route.path();
QMap<int,int> mapping;
// Force first mapping point to match the route start
mapping[0] = 0;
// Calculate the mapping between waypoints and via points
// Need two for loops to avoid getting stuck in local minima
for ( int j=1; j<route->size()-1; ++j ) {
qreal minDistance = -1.0;
for ( int i=mapping[j-1]; i<points.size(); ++i ) {
qreal distance = distanceSphere( points[i], route->at(j) );
if (minDistance < 0.0 || distance < minDistance ) {
mapping[j] = i;
minDistance = distance;
}
}
}
// Determine waypoint with minimum distance to the provided position
qreal minWaypointDistance = -1.0;
int waypoint=0;
for ( int i=0; i<points.size(); ++i ) {
qreal waypointDistance = distanceSphere( points[i], position );
if ( minWaypointDistance < 0.0 || waypointDistance < minWaypointDistance ) {
minWaypointDistance = waypointDistance;
waypoint = i;
}
}
// Force last mapping point to match the route destination
mapping[route->size()-1] = points.size()-1;
// Determine neighbor based on the mapping
QMap<int, int>::const_iterator iter = mapping.constBegin();
for ( ; iter != mapping.constEnd(); ++iter ) {
if ( iter.value() > waypoint ) {
int index = iter.key();
Q_ASSERT( index >= 0 && index <= route->size() );
return index;
}
}
return route->size()-1;
}
示例14: mid
GeoDataLineString GeoDataLineString::mid(int pos, int length) const
{
GeoDataLineString substring;
auto d = substring.d_func();
d->m_vector = d_func()->m_vector.mid(pos, length);
d->m_dirtyBox = true;
d->m_dirtyRange = true;
d->m_tessellationFlags = d_func()->m_tessellationFlags;
d->m_extrude = d_func()->m_extrude;
return substring;
}
示例15: handleItemMoving
void EditPolylineDialog::handleItemMoving( GeoDataPlacemark *item )
{
if( item == d->m_placemark ) {
d->m_nodeModel->clear();
if( d->m_placemark->geometry()->nodeType() == GeoDataTypes::GeoDataLineStringType ) {
GeoDataLineString *lineString = static_cast<GeoDataLineString*>( d->m_placemark->geometry() );
for( int i = 0; i < lineString->size(); ++i ) {
d->m_nodeModel->addNode( lineString->at( i ) );
}
}
}
}