Why a Custom Geocoding Service Fails in ArcGIS JavaScript API Page

1823
4
Jump to solution
12-27-2019 04:53 PM
by Anonymous User
Not applicable

I'm more of a desktop GIS developer, and I need some web GIS programming help.  The following URLs are public.  The JavaScript isn't obfuscated, so you should be able to see and read the source in developer mode within your browser.

First, check out https://maps.orem.org/MeterSearch.htm .  This web page can take two parameters in the URL.  You can append "?id=1234" to have the map zoom to a particular water meter ID, like 1234.  You should be able to also append an address with an addr query parameter.  The idea is that, if the meter can't be found by ID, then at least the address should be geocoded and the map should zoom in just like when the water meter ID is found.  So, if a negative meter ID is used above, and the house address is off by 2, the URL would look like this:

https://maps.orem.org/MeterSearch.htm?id=-1234&addr=575+E+Heather+Road

It should zoom to Heather Road, but it doesn't work.  Just so you know, the underlying geocoder is a custom one that I built which queries the geodatabase directly.  It uses a metaphone algorithm, linear algebra, dynamic segmentation, QGrams, and Utah house/street number switching to find the correct point.  A sample REST request for the address above would look like this, using an offset of 100 feet:

https://maps.orem.org/Geocoding/OremGeocoder.dll/rest/GeocodedAddress/?addr=98+N+State+Street&Offset...

The response is: {"x":1945693.56472451,"y":716049.690701424,"spatialReference":{"wkid":32043}}

The hyperlink to the meter map which includes the sample address should zoom to the suburbs.  The error I see in JavaScript is this:

dojo.js:354 [esri.core.accessorSupport.write] web-document-write:property-required Missing value for required property 'x' on 'esri.geometry.Point'

Clearly, x is in the REST response from the geocoder, so I'm lost.  Please help me fix this, ESRI Community!

"Roj"

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Roj,

   The issue is that your custom geocoding service is not handling an encoded url.

This fails:

https://maps.orem.org/Geocoding/OremGeocoder.dll/rest/GeocodedAddress/?addr=575%2BE%2BHeather%2BRoad...

But this works:

https://maps.orem.org/Geocoding/OremGeocoder.dll/rest/GeocodedAddress/?addr=575+E+Heather+Road&offse...

You need to decode the url in your dll before you try and resolve it in the geocoding.

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Roj,

   The issue is that your custom geocoding service is not handling an encoded url.

This fails:

https://maps.orem.org/Geocoding/OremGeocoder.dll/rest/GeocodedAddress/?addr=575%2BE%2BHeather%2BRoad...

But this works:

https://maps.orem.org/Geocoding/OremGeocoder.dll/rest/GeocodedAddress/?addr=575+E+Heather+Road&offse...

You need to decode the url in your dll before you try and resolve it in the geocoding.

by Anonymous User
Not applicable

I think this is on the right track, but I have a question.  Address parts are separated by spaces when written out.  The space character is encoded as %20 and the plus character is encoded as %2B, but I know that plus can replace space (though I'm not sure why).  So, in a way, I accept any URL's with pluses because I interpret them as spaces, but I don't think I want to accept %2B's, since those become literal pluses, which addresses shouldn't have.

Since the parameter to the meter search map already looks like this (addr=575+E+Heather+Road), can I pass that literally to my geocoder?  Or maybe I could decode and recode the URL?  How would I do that in JavaScript?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Roger,

  The esriRequest will url encode the request so your + will always get a %2B where it was a +. What you need to do is in your service code you need to url decode the parameters before attempting to do your query (not in JS, you need to do this on the service end). 

0 Kudos
by Anonymous User
Not applicable

I changed my DLL to replace pluses with spaces and it now works!  Thank you.  I'll mark your reply as an answer.

0 Kudos