Esempio n. 1
0
/**
 * @brief Gets the coordinates of a marker found at current model index.
 * @param index Current model index.
 * @param coordinates Here will be returned the coordinates of the current marker.
 * @return True, if the marker has coordinates.
 */
bool MapViewModelHelper::itemCoordinates(const QModelIndex& index, GeoIface::GeoCoordinates* const coordinates) const
{
    switch (d->application)
    {
        case MapWidgetView::ApplicationDigikam:
        {
            const ImageInfo info = d->model->imageInfo(index);

            if (info.isNull() || !info.hasCoordinates())
            {
                return false;
            }

            *coordinates = GeoIface::GeoCoordinates(info.latitudeNumber(), info.longitudeNumber());
            break;
        }

        case MapWidgetView::ApplicationImportUI:
        {
            const CamItemInfo info = d->importModel->camItemInfo(index);

            if (info.isNull())
            {
                return false;
            }

            const DMetadata meta(info.url().toLocalFile());
            double          lat, lng;
            const bool      haveCoordinates = meta.getGPSLatitudeNumber(&lat) && meta.getGPSLongitudeNumber(&lng);

            if (!haveCoordinates)
            {
                return false;
            }

            GeoIface::GeoCoordinates tmpCoordinates(lat, lng);

            double     alt;
            const bool haveAlt = meta.getGPSAltitude(&alt);

            if (haveAlt)
            {
                tmpCoordinates.setAlt(alt);
            }

            *coordinates = tmpCoordinates;
            break;
        }
    }

    return true;
}
Esempio n. 2
0
void Cube::CreateNeighbours(const std::vector<int> &coordinates)
{
  // Create a copy of the origin coordinates that will be adjusted for
  // each neighbour.
  std::vector<int> tmpCoordinates(coordinates);

  // Create each neighbour along the vertex beam dimensions.
  for (std::size_t i = 0; i < coordinates.size()-1; ++i) {
    int x = coordinates[i];
    if (m_bundle.beams[i]->size() > x+1) {
      ++tmpCoordinates[i];
      CreateNeighbour(tmpCoordinates);
      --tmpCoordinates[i];
    }
  }
  // Create the neighbour along the translation dimension.
  int x = coordinates.back();
  if (m_bundle.translations->GetSize() > x+1) {
    ++tmpCoordinates.back();
    CreateNeighbour(tmpCoordinates);
    --tmpCoordinates.back();
  }
}