Skip to content

Geocoder Not Returning Valid JSON for Nominatim and Photon #1692

Open
@devxiongmao

Description

@devxiongmao

Issue Description

Hi Alex, awesome work with this. I love Geocoder! I'm having an issue when I attempt to use Geocoder using the CLI and in my rails app. In my rails app, I have a priority list for Geocoder APIs (Azure first, followed by nominatim, then photon). While doing some testing, I found that nominatim and photon weren't responding with valid JSON. In my rails app, I consistently get Geocoding API's response was not valid JSON for these two lookups. However, Azure is working perfectly with my API key.

I tried to dig a little deeper using the CLI, and found that each lookup had a separate issue. Might anyone be able to shed some light on why this is happening? Is this expected behavior or something I might be misconfiguring?

Steps to Reproduce

  1. Using the CLI, run:
    geocode -s nominatim -j "350 Victoria Street, Toronto, Ontario, Canada"
  2. Then run:
    geocode -s photon -j "350 Victoria Street, Toronto, Ontario, Canada"
  3. Observe the outputs.

Outputs

geocode -s nominatim -j "350 Victoria Street, Toronto, Ontario, Canada"

<html>
<head>
<title>Access blocked</title>
</head>
<body>
<h1>Access blocked</h1>

<p>You have been blocked because you have violated the
<a href="https://operations.osmfoundation.org/policies/nominatim/">usage policy</a>
of OSM's Nominatim geocoding service. Please be aware that OSM's resources are
limited and shared between many users. The usage policy is there to ensure that
the service remains usable for everybody.</p>

<p>Please review the terms and make sure that your
software adheres to the terms. You should in particular verify that you have set a
<b>custom HTTP referrer or HTTP user agent</b> that identifies your application, and
that you are not overusing the service with massive bulk requests.</p>

<p>If you feel that this block is unjustified or remains after you have adopted
your usage, you may contact the Nominatim system administrator at
[email protected] to have this block lifted.</p>
</body>
</head>
geocode -s photon -j "350 Victoria Street, Toronto, Ontario, Canada"
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.22.1</center>
</body>
</html>

Expected Behavior

Responses from both Nominatim and Photon return valid JSON so the Geocoder gem can parse them properly.

Environment

  • OS: macOS Sequoia 15.5
  • Geocoder Gem Version: geocoder (1.8.5)
  • Ruby version: 3.2.2
  • Rails version: 8.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions