- # Script to extract structured city and street data
- # from a running nominatim instance as CSV data
-
-
- require_once(dirname(dirname(__FILE__)).'/lib/init-cmd.php');
- ini_set('memory_limit', '800M');
-
- $aCMDOptions = array(
- "Export addresses as CSV file from a Nominatim database",
- array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
- array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
- array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
-
- array('output-type', '', 0, 1, 1, 1, 'str', 'Type of places to output (see below)'),
- array('output-format', '', 0, 1, 1, 1, 'str', 'Column mapping (see below)'),
- array('output-all-postcodes', '', 0, 1, 0, 0, 'bool', 'List all postcodes for address instead of just the most likely one'),
- array('language', '', 0, 1, 1, 1, 'str', 'Preferred language for output (local name, if omitted)'),
- array('restrict-to-country', '', 0, 1, 1, 1, 'str', 'Export only objects within country (country code)'),
- array('restrict-to-osm-node', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM node'),
- array('restrict-to-osm-way', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM way'),
- array('restrict-to-osm-relation', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM relation'),
- "\nAddress ranks: continent, country, state, county, city, suburb, street, path",
- "Additional output types: postcode, placeid (placeid for each object)",
- "\noutput-format must be a semicolon-separated list of address ranks. Multiple ranks",
- "can be merged into one column by simply using a comma-separated list.",
- "\nDefault output-type: street",
- "Default output format: street;suburb;city;county;state;country"
- );
- getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
-
- $aRankmap = array( 'continent' => 1,
- 'country' => 4,
- 'state' => 8,
- 'county' => 12,
- 'city' => 16,
- 'suburb' => 20,
- 'street' => 26,
- 'path' => 27
- );
-
- $oDB =& getDB();
-
- if (isset($aCMDResult['output-type']))
- {
+ // Script to extract structured city and street data
+ // from a running nominatim instance as CSV data
+
+
+ require_once(CONST_BasePath.'/lib/init-cmd.php');
+ require_once(CONST_BasePath.'/lib/ParameterParser.php');
+ ini_set('memory_limit', '800M');
+
+ $aCMDOptions = array(
+ 'Export addresses as CSV file from a Nominatim database',
+ array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
+ array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
+ array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
+
+ array('output-type', '', 0, 1, 1, 1, 'str', 'Type of places to output (see below)'),
+ array('output-format', '', 0, 1, 1, 1, 'str', 'Column mapping (see below)'),
+ array('output-all-postcodes', '', 0, 1, 0, 0, 'bool', 'List all postcodes for address instead of just the most likely one'),
+ array('language', '', 0, 1, 1, 1, 'str', 'Preferred language for output (local name, if omitted)'),
+ array('restrict-to-country', '', 0, 1, 1, 1, 'str', 'Export only objects within country (country code)'),
+ array('restrict-to-osm-node', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM node'),
+ array('restrict-to-osm-way', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM way'),
+ array('restrict-to-osm-relation', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM relation'),
+ "\nAddress ranks: continent, country, state, county, city, suburb, street, path",
+ 'Additional output types: postcode, placeid (placeid for each object)',
+ "\noutput-format must be a semicolon-separated list of address ranks. Multiple ranks",
+ 'can be merged into one column by simply using a comma-separated list.',
+ "\nDefault output-type: street",
+ 'Default output format: street;suburb;city;county;state;country'
+ );
+ getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
+
+ $aRankmap = array(
+ 'continent' => 1,
+ 'country' => 4,
+ 'state' => 8,
+ 'county' => 12,
+ 'city' => 16,
+ 'suburb' => 20,
+ 'street' => 26,
+ 'path' => 27
+ );
+
+ $oDB = new Nominatim\DB();
+ $oDB->connect();
+
+ if (isset($aCMDResult['output-type'])) {