Here's what I need to accomplish. So any help on this would be absolutely magnificent.
I've programmed in WinAPI32, but for fast development I'm looking to use QT IDE in order to connect
to an SQL database. I need to run queries on addresses for stored patience. The address
is to be stored as a string and my program needs to pass this to some other system
I'm hoping you can help suggest that will return the geo coordinates of that address.

I have found various online web sources that take in the address and return coordinates.
Without spending allot of time re-learning java, etc... or using wget to grab the page
and then stream input into the grabbed page only to get returned results is allot of
nasty coding. Is there an easier way ??

Dani AI

Generated

Building on ’s problem statement and the suggestions from (offline data) and (use a web API), here’s a compact, practical Qt + MySQL workflow that fills the gaps: how to call a geocoder from Qt, parse the result, store coordinates efficiently, and handle caching/rate limits so the solution scales.

  1. Workflow (high level)
  • Normalize the address string (simple normalization or use a library such as libpostal) and check a local cache table first.
  • If not cached, call a geocoding HTTP endpoint from Qt, parse the JSON, extract lat/lon.
  • Store latitude, longitude, the raw geocoder JSON and a timestamp in MySQL; also store a POINT column for spatial queries.
  • Respect provider rate limits (exponential backoff and batch requests) and cache every positive result.
  1. Minimal Qt sketch (JSON parsing + DB insert)

    QNetworkAccessManager *mgr = new QNetworkAccessManager(this);
    QUrl url(QString("https://your-geocoder.example/geocode?address=%1")
          .arg(QUrl::toPercentEncoding(address)));
    QNetworkReply *rep = mgr->get(QNetworkRequest(url));
    connect(rep, &QNetworkReply::finished, this, [rep, address]() {
     QByteArray data = rep->readAll();
     QJsonDocument doc = QJsonDocument::fromJson(data);
     // parse provider-specific JSON to get lat / lon:
     double lat = /* extract from doc */;
     double lon = /* extract from doc */;
    
     QSqlQuery q;
     q.prepare("INSERT INTO addresses (address, latitude, longitude, location, geocode_json, geocoded_at) "
               "VALUES (:addr, :lat, :lon, ST_GeomFromText(:pt,4326), :json, NOW())");
     q.bindValue(":addr", address);
     q.bindValue(":lat", lat);
     q.bindValue(":lon", lon);
     q.bindValue(":pt", QString("POINT(%1 %2)").arg(lon).arg(lat));
     q.bindValue(":json", QString::fromUtf8(data));
     q.exec();
    });

    Parsing and the exact SQL depend on the chosen service and MySQL version; adapt field names accordingly.

  2. Practical notes / troubleshooting

  • Cache aggressively: identical addresses should never be re-geocoded unnecessarily. Store normalized-address -> lat/lon mappings.
  • Use MySQL’s spatial type (POINT) and a SPATIAL INDEX for fast proximity queries (store WGS84 / SRID 4326).
  • Batch requests when possible and implement retries with exponential backoff; log failed lookups for manual review.
  • For offline/full-control needs, run a local geocoding server or use an address-to-coordinates dataset and a spatial index; this avoids rate limits but requires more setup and periodic data updates.
  • Always record the raw geocoder response and the geocoding timestamp so future reprocessing or vendor changes are auditable.

This gives a lightweight, native-Qt path that avoids re-learning large stacks while remaining robust and scalable.

Recommended Answers

All 2 Replies

How accurate do the address coordinates need to be? You could download an open source dataset.

I think that both Google Maps and Nokia's Here have API's that can do that for you (probable web services APIs). You need to do some research on their sites for this. When you pull up Google Maps or Here on your computer or phone, and input an address, it will zoom in on the exact location without problems. You could investigate the HTML/Javascript code that your browser executes to figure that out as well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.