Changeset d488c37 in subsurface


Ignore:
Timestamp:
Feb 12, 2015, 11:19:27 AM (3 years ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
Mtest, android_test, dcDownload, foratdotde, gitMerge, gitdebug, gitpictures, ios, master, mergeKirigamiPort, pictimeshift, resolutionIndependence, spinner, testTomaz, testing, v4.5-branch
Children:
801e584
Parents:
9ef81d3
git-author:
Dirk Hohndel <dirk@…> (02/12/15 01:19:07)
git-committer:
Dirk Hohndel <dirk@…> (02/12/15 11:19:27)
Message:

Show dive coordinates on map based on dive site

Signed-off-by: Dirk Hohndel <dirk@…>

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • dive.h

    r4b15b9d rd488c37  
    506506}
    507507
     508static inline struct dive_site *get_dive_site_for_dive(struct dive *dive)
     509{
     510        if (dive)
     511                return get_dive_site_by_uuid(dive->dive_site_uuid);
     512        return NULL;
     513}
     514
    508515static inline unsigned int number_of_computers(struct dive *dive)
    509516{
  • qt-ui/globe.cpp

    r6b038c2 rd488c37  
    165165        for_each_dive (idx, dive) {
    166166                long lat_diff, lon_diff;
    167                 if (!dive_has_gps_location(dive))
     167                struct dive_site *ds = get_dive_site_for_dive(dive);
     168                if (!dive_site_has_gps_location(ds))
    168169                        continue;
    169                 lat_diff = labs(dive->latitude.udeg - lat_udeg);
    170                 lon_diff = labs(dive->longitude.udeg - lon_udeg);
     170                lat_diff = labs(ds->latitude.udeg - lat_udeg);
     171                lon_diff = labs(ds->longitude.udeg - lon_udeg);
    171172                if (lat_diff > 180000000)
    172173                        lat_diff = 360000000 - lat_diff;
     
    187188void GlobeGPS::repopulateLabels()
    188189{
     190        struct dive_site *ds;
    189191        if (loadedDives) {
    190192                model()->treeModel()->removeDocument(loadedDives);
     
    205207                        // or it's the one that we are moving right now...
    206208                        continue;
    207                 if (dive_has_gps_location(dive)) {
    208                         GeoDataPlacemark *place = new GeoDataPlacemark(dive->location);
    209                         place->setCoordinate(dive->longitude.udeg / 1000000.0, dive->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree);
     209                ds = get_dive_site_for_dive(dive);
     210                if (dive_site_has_gps_location(ds)) {
     211                        GeoDataPlacemark *place = new GeoDataPlacemark(ds->name);
     212                        place->setCoordinate(ds->longitude.udeg / 1000000.0, ds->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree);
    210213                        // don't add dive locations twice, unless they are at least 50m apart
    211                         if (locationMap[QString(dive->location)]) {
    212                                 GeoDataCoordinates existingLocation = locationMap[QString(dive->location)]->coordinate();
     214                        if (locationMap[QString(ds->name)]) {
     215                                GeoDataCoordinates existingLocation = locationMap[QString(ds->name)]->coordinate();
    213216                                GeoDataLineString segment = GeoDataLineString();
    214217                                segment.append(existingLocation);
     
    221224                                        continue;
    222225                        }
    223                         locationMap[QString(dive->location)] = place;
     226                        locationMap[QString(ds->name)] = place;
    224227                        loadedDives->append(place);
    225228                }
     
    237240void GlobeGPS::centerOnCurrentDive()
    238241{
    239         struct dive *dive = current_dive;
     242        struct dive_site *ds = get_dive_site_for_dive(current_dive);
    240243        // dive has changed, if we had the 'editingDive', hide it.
    241         if (messageWidget->isVisible() && (!dive || dive_has_gps_location(dive) || amount_selected != 1))
     244        if (messageWidget->isVisible() && (!ds || dive_site_has_gps_location(ds) || amount_selected != 1))
    242245                messageWidget->hide();
    243246
    244247        editingDiveLocation = false;
    245         if (!dive)
    246                 return;
    247 
    248         qreal longitude = dive->longitude.udeg / 1000000.0;
    249         qreal latitude = dive->latitude.udeg / 1000000.0;
    250 
    251         if ((!dive_has_gps_location(dive) || MainWindow::instance()->information()->isEditing()) && amount_selected == 1) {
     248        if (!ds)
     249                return;
     250
     251        qreal longitude = ds->longitude.udeg / 1000000.0;
     252        qreal latitude = ds->latitude.udeg / 1000000.0;
     253
     254        if ((!dive_site_has_gps_location(ds) || MainWindow::instance()->information()->isEditing()) && amount_selected == 1) {
    252255                prepareForGetDiveCoordinates();
    253256                return;
    254257        }
    255         if (!dive_has_gps_location(dive)) {
     258        if (!dive_site_has_gps_location(ds)) {
    256259                zoomOutForNoGPS();
    257260                return;
     
    310313}
    311314
     315// This needs to update the dive site, not just this dive
    312316void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
    313317{
     318        struct dive_site *ds;
    314319        messageWidget->hide();
    315320
     
    325330
    326331        // change the location of the displayed_dive and put the UI in edit mode
    327         displayed_dive.latitude.udeg = lrint(lat * 1000000.0);
    328         displayed_dive.longitude.udeg = lrint(lon * 1000000.0);
     332        ds = get_dive_site_for_dive(&displayed_dive);
     333        ds->latitude.udeg = lrint(lat * 1000000.0);
     334        ds->longitude.udeg = lrint(lon * 1000000.0);
    329335        emit(coordinatesChanged());
    330336        repopulateLabels();
Note: See TracChangeset for help on using the changeset viewer.