Openstreetmap-website: API threw unexpected NoMethodError exception: undefined method `visible?' for nil:NilClass

Created on 11 Dec 2013  路  5Comments  路  Source: openstreetmap/openstreetmap-website

Hello all

I built a openstreetmap api server on Ubuntu 12.04, using ruby 1.9.3 with latest stable version of openstreetmap-website, running puma webserver(-t 4:16 -w 3), imported latest osm data to postgresql 9.3

"API threw unexpected NoMethodError exception: undefined method `visible?' for nil:NilClass" happens when I try to download larger data by JOSM. Error always happens if I download data with area greater than 1km*1km approximately.

Is there any way to solve this problem?

Most helpful comment

When using extracts I make the following change to the rails code, which means that relation won't be guaranteed to be valid. It's great, but for some purposes it'll work:

@@ -137,7 +137,7 @@ def to_xml_node(visible_members = nil, changeset_cache = {}, user_display_name_c
          end
        else
          # otherwise, manually go to the db to check things
 -        if member.member.visible?
 +        if member.member && member.member.visible?
            p=1
          end
        end

All 5 comments

At a guess you have imported a partial data set and you have relations that refer to members that do not exist in your database - this is a problem with the data you have loaded, not with the web site code.

I see, I am using the data from http://download.geofabrik.de/asia.html, imported taiwan.osm to my database. I will try other osm files for testing.

thanks for help

Trying another extract probably won't help much - the problem is that extracts typically include all nodes and ways in the given area, plus any relations that include one of those nodes or ways. What they don't include is any other nodes and ways which are in the relation but are outside the area of the extract.

Hence when you load the data into the API database it will not have referential integrity because you will have relations that refer to nodes or ways that do not exist.

When using extracts I make the following change to the rails code, which means that relation won't be guaranteed to be valid. It's great, but for some purposes it'll work:

@@ -137,7 +137,7 @@ def to_xml_node(visible_members = nil, changeset_cache = {}, user_display_name_c
          end
        else
          # otherwise, manually go to the db to check things
 -        if member.member.visible?
 +        if member.member && member.member.visible?
            p=1
          end
        end

great solution, thanks for help @smsm1

Otherwise I was going to download the completed version of planet.osm and extract the country I want.

Was this page helpful?
0 / 5 - 0 ratings