Re: Migrating https://api.geo.admin.ch/swisssearch/geocoding to https://api3.geo.admin.ch/rest/services/api/SearchServer

195 views
Skip to first unread message

Marc Monnerat

unread,
Apr 15, 2014, 12:04:20 PM4/15/14
to geoadmin-api
Hello,

Well, the 'SearchServer' service is using Sphinx Search as backend and it has not every possible feature's attributes (fast, but 'optimized'). The other services are querying the spatial database directly ('slow', but complete). So you have to follow http://api3.geo.admin.ch/services/sdiservices.html#example-of-feature-search-usage-with-other-services


Canton, e.g. 'Bern'

then



Commune, e.g. 'Versoix'

and then



Adresses, e.g.'chemin Isabelle de Montolieu'

and 



Hope it makes sense.

Marc





2014-04-15 15:30 GMT+02:00 <msc...@puzzle.ch>:
Hello,

In a project for the Swiss government, for which we do the maintenance and support, we are
currently using the REST API 2.5 from api.geo.admin.ch. As we were informed by the customer
this API will shortly be deprecated.

During the analysis of the new version 3.0 we figured out, that some of the features we
were using, are not explicitly available in the API 3.0. Therefore we maybe need a little
help/input from your side.

We are using the geo.admin.ch API to:
  - Search Towns (Orte, Gemeinden)
  - Search Streets (Strassen)

With the API 2.5 we used the following services:

Search for towns (Orte)
  Sample request Towns: https://api.geo.admin.ch/swisssearch/geocoding?query=Bern&no_geom=true&format=raw
  The result is then filtered, to have a clean result list: origin not-in ['address', 'district', 'kantone'] &&  objectorig <> 'sn25'
  Return value: name or gemname (gemname, kanton)

Streets (Strassen):
  Sample request: https://api.geo.admin.ch/swisssearch/geocoding?query=Eigerpl&no_geom=true&format=raw&services=address
  Return value: strname1 deinr (ort_27)

Now the major issue is, that the parameter format=raw (returns all the available properties of the selected feature(s)) which
was available in API 2.5 does no longer exist in API 3.0.

One option would be to use the “feature_id” found in “attrs” to get detailed information about a feature but
this would lead into a 1 to n problem which which will most likely cause performance troubles, as we have in
general pretty long result lists.

What would you propose? Is there maybe an other elegant way to get towns and streets separately?

Thanks in advance for your support
Marc Schmid


--
You received this message because you are subscribed to the Google Groups "GeoAdmin API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-- Τα πάντα ῥεῖ καὶ οὐδὲν μένει

msc...@puzzle.ch

unread,
Apr 22, 2014, 8:01:30 AM4/22/14
to geoadm...@googlegroups.com
Hello,

Thanks for your answer, but the solution that you describe below will lead to the 1 to n problem. For building up a list a list of 50 entries we have to do 51 REST-queries which will not be fast at all.

Is there really no replacement for the "format=raw" feature from the old service?

Is there no direct way to ... 

 - execute ONE query with a part of a town name (Gemeinde) and get a full list of found entries, that contains at least the fields 'gemname' and 'kanton'
 - execute ONE query with a part of a street name (Strasse) and get a full list of found entries, that contains at least the files 'strname1' 'deinr' and 'ort_27'

Hint: The field names above are the names from the old service. If there are fields with the same values in the new service we can use them.

Thanks in advance for your help.
Marc Schmid

Gilbert Jeiziner

unread,
Apr 23, 2014, 1:30:43 AM4/23/14
to geoadm...@googlegroups.com
Hello Marc,

we have the find service (as documented in our guide [1]), which
might be used for what you want to do.

The trouble with this service is to find out a) which layer you need to
query and b) which fields of the layer you can query. Let's take 
'Gemeinden' as an example. The layer corresponding to
Gemeindegrenzen can be used in the find service:
ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill

To find out which fields/attribues you can query, you can issue
a layer metadata command:

To find a town containing a specific name, you would use the find service as follows:

For addresses, you could use the layer 'ch.bfs.gebaeude_wohnungs_register'

Let us know if this covers your use case

Gilbert

PS The search service is optimized for speed and therefore lacks in other areas

msc...@puzzle.ch

unread,
May 12, 2014, 6:35:47 AM5/12/14
to geoadm...@googlegroups.com, g...@space.ch
Hello geo.admin.ch Team

We found a reasonable solution for the search of towns. But for the search of address we still lack of the optimal solution. The issue we currently have is the following:

If we do the search using the locations search of SearchServer the returned results are pretty nice and would match our needs. For example if we search for "Schulgasse" we get a lot of results of "Schulgasse"s in many differen towns. This is what we need. BUT in the results we do not have the field "feature_id" or any other usable id to get further details of the address.
http://api3.geo.admin.ch/rest/services/api/SearchServer?searchText=Schulgasse&type=locations

On the other hand we could do a featuresearch on SearchServer there we have the feature_id in the results but in this case we get a lot of results for each street from the same towns (in this case Schwyz, Murten, Winterthur). Due to the limited result set we do not get results from towns like Buchs or Merzligen and many others that we would get when when we do a locations search. So this is not really a solution for us.
http://api3.geo.admin.ch/rest/services/api/SearchServer?features=ch.bfs.gebaeude_wohnungs_register&type=featuresearch&searchText=Schulgasse

Basically we would like to use the locations search as it produces the results that we need. But the issue is that from the result of the locations search we can not extract any usable id or other information to do a detail request to get all details of an address. Basically we are missing the feature_id in the result of the locations search.

To get the details of an address we could use for example
http://api3.geo.admin.ch/rest/services/api/MapServer/find?layer=ch.bfs.gebaeude_wohnungs_register&searchText=261372&searchField=egid&returnGeometry=false
or better
http://api3.geo.admin.ch/rest/services/api/MapServer/ch.bfs.gebaeude_wohnungs_register/261372_0
if we have the feature_id

How would you solve this?

Thanks in advance
Marc Schmid

Moullet Cédric swisstopo

unread,
May 13, 2014, 4:52:18 AM5/13/14
to geoadm...@googlegroups.com, g...@space.ch

Hello,

Thanks for your mail.

We will add the feature id in the location search. You can expect to have this until the end of the month.

Best regards,

Cédric

 

De : geoadm...@googlegroups.com [mailto:geoadm...@googlegroups.com] De la part de msc...@puzzle.ch
Envoyé : lundi 12 mai 2014 12:36
À : geoadm...@googlegroups.com
Cc : g...@space.ch
Objet : Re: Migrating https://api.geo.admin.ch/swisssearch/geocoding to https://api3.geo.admin.ch/rest/services/api/SearchServer

--

msc...@puzzle.ch

unread,
May 13, 2014, 6:13:41 AM5/13/14
to geoadm...@googlegroups.com, g...@space.ch
Hello,

Thanks a lot, that are really cool news!

Can we expect to have a result like the one below from http://api3.geo.admin.ch/rest/services/api/SearchServer?searchText=Schulgasse&type=locations after your updated is installed?

{
    "results": [
        {
            "id": 581047,
            "weight": 12,
            "attrs": {
                "origin": "address",
                "detail": "schulgasse  4105 biel-benken bl 2764 biel-benken ch bl",
                "rank": 6,
                "num": 0,
                "y": 606716.0,
                "x": 261818.0,
                "feature_id": "261372_0",
                "label": "Schulgasse  <b>4105 Biel-Benken BL</b>"
            }
        },
     .....

I ask as we have to pre-prepare the shipment to our customer to be able to deliver as soon as the feature is available.

Could you please post a message here, when the feature_id is available in order to allow us to ship immediately to our customer. Thanks in Advance.

Kind regards
Marc Schmid

Moullet Cédric swisstopo

unread,
May 13, 2014, 6:53:27 AM5/13/14
to geoadm...@googlegroups.com, g...@space.ch, Clausen Marcel swisstopo

Yes, you can expect to have feature_id. In addition, a layer parameter will reference the corresponding layer.

Best regards,

Cédric

 

De : geoadm...@googlegroups.com [mailto:geoadm...@googlegroups.com] De la part de msc...@puzzle.ch
Envoyé : mardi 13 mai 2014 12:14

Reply all
Reply to author
Forward
0 new messages