devel_generate module allows to create a defined amount of contents for testing purpose.

Integrating getlocations_fields with devel_generate could be use full to have locations data fields inserted as well.

Comments

drikc created an issue. See original summary.

drikc’s picture

Issue summary: View changes
drikc’s picture

Status: Active » Needs review
StatusFileSize
new1.5 KB

The attached patch integrates with devel_generate module and use http://www.geonames.org/ web service to randomly get some place names and their coordinates.

The geonames webservice use a username parameter and which is set with a 'demo' string by default. Using this value may render to no response depending on it has been trigger too many times... This default username can be changed by setting the 'geonames_webservice_username_parameter' variable (a specific login can be obtain here: http://www.geonames.org/login).

  • hutch committed f2e4dda on 7.x-1.x
    devel_generate support added, see #2603376
    

  • hutch committed a10d82c on
    devel_generate support added, see #2603376
    
hutch’s picture

Patch went in fine, tested with 10 places using the defaults and they were all created.
This has been commited to 1.x and 2.x dev.
@drikc, Thank you for this excellent contribution!

hutch’s picture

Status: Needs review » Reviewed & tested by the community
drikc’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.01 KB

The attached patch prevent an infinite loop if the geonames web service fail for some reasons (unknown username, limit exceeded, ...).

Note, that this patch must be applied after the first one!

hutch’s picture

Patch in #8 is good and will be commited.

drikc’s picture

Small add-on over patch #8; it fill in also the country column (in addition to name, lat and lng colunmns).

hutch’s picture

I've just had a look at the geonames API to see just what exactly gets returned, 'countryCode' is fine, it is uppercase which is what we want.
I also see a field 'asciiName' which will print in any language, the 'name' field could contain characters unique to the country. Does anyone have any thoughts on this?
eg

{"geonames": [{
  "distance": "1.1379",
  "timezone": {
    "gmtOffset": 1,
    "timeZoneId": "Europe/Zurich",
    "dstOffset": 2
  },
  "asciiName": "Chruezegg",
  "countryId": "2658434",
  "fcl": "P",
  "adminId2": "7285001",
  "adminId3": "7286562",
  "countryCode": "CH",
  "adminId1": "2658821",
  "lat": "47.2985",
  "fcode": "PPLX",
  "continentCode": "EU",
  "elevation": 0,
  "adminCode2": "1727",
  "adminCode3": "3394",
  "adminCode1": "SG",
  "lng": "9.01488",
  "geonameId": 7910950,
  "toponymName": "Chrüzegg",
  "population": 0,
  "adminName5": "",
  "adminName4": "",
  "adminName3": "Mosnang",
  "adminName2": "Wahlkreis Toggenburg",
  "name": "Chrüzegg",
  "fclName": "city, village,...",
  "countryName": "Switzerland",
  "fcodeName": "section of populated place",
  "adminName1": "Saint Gallen"
}]}
drikc’s picture

Reading http://download.geonames.org/export/dump/readme.txt we have the following definitions for fields:
name : name of geographical point (utf8) varchar(200)
country code : ISO-3166 2-letter country code, 2 characters

hutch’s picture

OK, most browsers support utf8 and the db should too so keep 'name'.

  • hutch committed 9de7038 on 7.x-1.x
    better devel_generate, see #2603376
    
  • hutch committed c928625 on 7.x-1.x
    better devel_generate, see #2603376
    

  • hutch committed 15c3fc0 on
    better devel_generate, see #2603376
    
  • hutch committed d81f454 on
    better devel_generate, see #2603376