Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new geocoding provider: Bing (Locations API) #505

Merged
merged 236 commits into from
Nov 29, 2023
Merged

Add new geocoding provider: Bing (Locations API) #505

merged 236 commits into from
Nov 29, 2023

Conversation

Raruto
Copy link
Collaborator

@Raruto Raruto commented Oct 16, 2023

Depends on:

Premise

  1. As per 2023/10 Bing Local Search API supports searches for business entities only in the USA.
  2. Dynamic field mapping is currently not supperted while saving geocoding results into a project layer (ie. target layers must have the same field names as the resulting geocoding fields to work correctly, see: available bing attributes and sample target editable layer).
  3. autogenerated fields (which do not collide with each other) are also mappable without using the provider prefix (and using lower case notation), eg:
    • bing_Websitewebsite
    • bing_Address_postalCodeaddress_postalcode
    • bing_Address_localityaddress_locality

Docker settings

# config/g3w-suite/settings_docker.py

VENDOR_KEYS = {
 'bing': 'your.super.secret.key'
}

GEOCODING_PROVIDERS = {
  "nominatim": {
    "label": "Nominatim (OSM)",
    "url": "https://nominatim.openstreetmap.org/search",
    # "icon": "road",
  },
  "bing_streets": {
    "label": "Bing Streets",
    "url": "https://dev.virtualearth.net/REST/v1/Locations/?key=" + VENDOR_KEYS['bing'], # + '&inclnb=1',
    # "icon": "road",
  },
  "bing_places": {
    "label": "Bing Places",
    "url": "https://dev.virtualearth.net/REST/v1/LocalSearch/?key=" + VENDOR_KEYS['bing'],
    # "icon": "poi",
  },
}

To set a vendor key you can do as is most comfortable for you, e.g.:

  • ?key=" + VENDOR_KEYS['bing'] ← passing it directly into the url
  • VENDOR_KEYS['bing'] = "super.secret.key" ← setting a generic global key
  • VENDOR_KEYS['bing_search'] = "super.secret.key" ← setting a specific key to that service

If you would like to add new providers (or rename existing ones), just remember to use the file name as "provider" identifier:

http://localhost:8000/static/client/geocoding-providers/bing_streets.js
http://localhost:8000/static/client/geocoding-providers/bing_places.js
http://localhost:8000/static/client/geocoding-providers/nominatim.js
http://localhost:8000/static/client/geocoding-providers/my_custom_provider.js
...
# config/g3w-suite/settings_docker.py

GEOCODING_PROVIDERS = {
  "bing_streets": { ... },
  "bing_places":  { ... },
  "nominatim":    { ... },
  "my_custom_provider": {
    "label": "Custom Provider",
    "url": "https://example.com/search"
  },
}

VENDOR_KEYS['my_custom_provider'] = 'super.secret.key' 

How to test

  1. download demo-geocoding.zip and create a new project within g3w-admin
  2. set all point layers as editable
  3. perform a geocoding search (eg. cafe)

image

Add new feature from geocoding results (bing or nominatim)

image

image

Available attributes (bing)

image

Available attributes (nominatim)

image

Sample QGIS layer (target editable point layer)

image

Closes: #498

@Raruto Raruto added the feature New feature or request label Oct 16, 2023
@Raruto Raruto added this to the v3.9 milestone Oct 16, 2023
@Raruto Raruto marked this pull request as draft October 16, 2023 10:56
@Raruto Raruto mentioned this pull request Nov 17, 2023
1 task
volterra79 and others added 7 commits November 20, 2023 15:12
…an one feature. In this case when info is not collapsed, hide header previous fields and values
- add folder `src/assets/gecoding-providers`
- extract `bing` into two new providers → `bing_places` and `bing_streets` (ref: #498 (comment))
- new gulp task `geocoding-providers`
Copy link
Collaborator Author

@Raruto Raruto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wlorenzetti @volterra79 you can update your docker settings as follows to test:

# config/g3w-suite/settings_docker.py

VENDOR_KEYS = {
 'bing': 'your.super.secret.key'
}

GEOCODING_PROVIDERS = {
  "nominatim": {
    "label": "Nominatim (OSM)",
    "url": "https://nominatim.openstreetmap.org/search",
    # "icon": "road",
  },
  "bing_streets": {
    "label": "Bing Streets",
    "url": "https://dev.virtualearth.net/REST/v1/Locations/?key=" + VENDOR_KEYS['bing'], # + '&inclnb=1',
    # "icon": "road",
  },
  "bing_places": {
    "label": "Bing Places",
    "url": "https://dev.virtualearth.net/REST/v1/LocalSearch/?key=" + VENDOR_KEYS['bing'],
    # "icon": "poi",
  },
}

To set a vendor key you can do as is most comfortable for you, e.g.:

  • ?key=" + VENDOR_KEYS['bing'] ← passing it directly into the url
  • VENDOR_KEYS['bing'] = "super.secret.key" ← setting a generic global key
  • VENDOR_KEYS['bing_search'] = "super.secret.key" ← setting a specific key to that service

If you would like to add new providers (or rename existing ones), just remember to use the file name as "provider" identifier:

http://localhost:8000/static/client/geocoding-providers/bing_streets.js
http://localhost:8000/static/client/geocoding-providers/bing_places.js
http://localhost:8000/static/client/geocoding-providers/nominatim.js
http://localhost:8000/static/client/geocoding-providers/my_custom_provider.js
...
# config/g3w-suite/settings_docker.py

GEOCODING_PROVIDERS = {
  "bing_streets": { ... },
  "bing_places":  { ... },
  "nominatim":    { ... },
  "my_custom_provider": {
    "label": "Custom Provider",
    "url": "https://example.com/search"
  },
}

VENDOR_KEYS['my_custom_provider'] = 'super.secret.key' 

wlorenzetti added a commit to g3w-suite/g3w-admin that referenced this pull request Nov 24, 2023
* Add GEOCODING_PROVIDERS setting.

* Add geocoding_providers to qdjango.project model.

* Update base settings GEOCODING_PROVIDERS.

* Add qdjango utility: get_geocoding_providers.

* Add geocoding_provider CRUD.

* Change initconfig API REST proeperty group.mapcontrols from list to dict.

* Fix for update projects with geocoding_providers empty or None.

* Check for geocoding_providers is empty.

* Update geoconding_providers qdjango.project field for backward compatibility.

* Fix test.

* Add sql to migration for change mapcontrol nominatim in geocoding

* Update mapcontrol structure

* Change from 'provider' to 'providers' inside the options of mapcontrol 'geocoding'.

* Change from 'provider' to 'providers' inside the options of mapcontrol 'geocoding'.

* ⬆️ Client:
    g3w-client : g3w-suite/g3w-client#505
    editing: g3w-suite/g3w-client-plugin-editing#72

* ⬆️ Client:
    g3w-client : g3w-suite/g3w-client@bf79291

* ⬆️ Client:
    g3w-client : g3w-suite/g3w-client@d610c3e

* Small fix.

* Typo.

* Add email exists check on recovery username form.

* Refactoring and add settings to reset password and user recovery email templates.

* ✨ Change password at first login (#650)

* Add PASSWORD_CHANGE_FIRST_LOGIN setting.

* Add change_password_first_login property to Userdata model.

* Create custom G3WSetPasswordForm and custom G3WLoginView to use for change password at first login workflow.

* Start testing.

* Testing.

* Split change password at first login from reset password workflow.

* Create a custom view for confirm reset password to split User rest password workflow from Change password at first login worflow.

* Override settings fix.

---------

Co-authored-by: wlorenzetti <lorenzett@gis3w.it>

* ✨ Add support to qgis `'postgresraster'` layer (#652)

* Add 'postgresraster' qgis layer type support.

* ⬆️ Client:
    g3w-client :g3w-suite/g3w-client#519

---------

Co-authored-by: wlorenzetti <lorenzett@gis3w.it>
Co-authored-by: volterra79 <boccacci.francesco@gmail.com>

* Fix get filter layer saved with anonymous user. (#654)

Co-authored-by: wlorenzetti <lorenzett@gis3w.it>

* Typo

* Fix importing project with RelationReference widget

* Fix migrations.

* ⬆️ Client:
    g3w-client : g3w-suite/g3w-client@1a8c128

* ⬆️ Client:
    g3w-client : g3w-suite/g3w-client#505

* ⬆️ Client:
    g3w-client : g3w-suite/g3w-client#505 Missing svg icon

* ⬆️ Client:
    g3w-client : g3w-suite/g3w-client@23227b6

* ⬆️ Client:
    g3w-client : g3w-suite/g3w-client@573bc3b

* ⬆️ Client:
    g3w-client :g3w-suite/g3w-client@bfd21d6
    g3w-client-plugin-editing: g3w-suite/g3w-client-plugin-editing@546be8b

* ⬆️ Client:
    g3w-client-plugin-editing: g3w-suite/g3w-client-plugin-editing@8e2a163

* ⬆️ Client:
    g3w-client-plugin-editing: g3w-suite/g3w-client-plugin-editing@bfc43de

* ⬆️ Client:
    g3w-client-plugin-editing: g3w-suite/g3w-client-plugin-editing@cfd558d

* ⬆️ Client:
    g3w-client: g3w-suite/g3w-client@7ac2a8c

* mispelling

* ⬆️ Client:
    g3w-client: g3w-suite/g3w-client@ad1b3c2
    g3w-client-plugin-editing: g3w-suite/g3w-client-plugin-editing@21cc247

* Remove 'Bing' from default value of 'GEOCODING_PROVIDERS' setting.

* ⬆️ Client:
    g3w-client: g3w-suite/g3w-client@b23276b

* ⬆️ Client:
    g3w-client: Add geocoding providers folder

---------

Co-authored-by: wlorenzetti <lorenzett@gis3w.it>
Co-authored-by: volterra79 <boccacci.francesco@gmail.com>
Co-authored-by: Raruto <Raruto@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bings Maps geocoding control
3 participants