The openaddresses-plugin plugin can be used to generate real addresses from
the OpenAddresses project. The plugin uses
geojson files from the project to generate addresses.
Before using the plugin, you need to initialize the plugin in the
plugin options.
The plugin takes the following options:
files: A single string or an array of strings containing the
paths to the files to use. The files should be in the geojson format.backend: The plugin has two backends: memory and sqlite. The
memory backend loads the entire file into memory, while the sqlite
backend loads the file into a sqlite database. The sqlite backend is
slower than the memory backend but uses less memory. The default
backend is memory. If the sqlite backend is used, the plugin requires
a path to the sqlite database file. The database file will be created if
it does not exist.memory backendjson
{
"options": {
"plugins": {
"openaddresses-plugin": {
"path": "/path/to/openaddresses_plugin",
"args": {
"files": ["/path/to/geojson/file1", "/path/to/geojson/file2"],
"backend": {
"type": "memory"
}
}
}
}
}
}
sqlite backendThis will initialize the sqlite backend and create a sqlite database
at /path/to/sqlite/database.db. The database will be populated with
the data from the geojson files, which may take some time. If the
database already exists, it will be used instead of creating a new one.
json
{
"options": {
"plugins": {
"openaddresses-plugin": {
"path": "/path/to/openaddresses_plugin",
"args": {
"files": ["/path/to/geojson/file1", "/path/to/geojson/file2"],
"backend": {
"type": "sqlite",
"databaseName": "/path/to/sqlite/database.db"
}
}
}
}
}
}
In order to use the plugin, provide the openaddresses-plugin plugin
name in the plugin generator.
The plugin accepts an object containing the names of the properties to generate as keys and the fields to use as values. The following field types are supported:
number: The number of addresses to generate.street: The street name.city: The city name.unit: The unit number.district: The district name.region: The region name.postcode: The postcode.latitude: The latitude.longitude: The longitude.The objects may also be nested, to create nested objects.
json
{
"type": "plugin",
"pluginName": "openaddresses-plugin",
"args": {
"street": "street",
"houseNumber": "number",
"city": "city",
"coordinates": {
"latitude": "latitude",
"longitude": "longitude"
}
}
}
This will produce an object like this:
json
{
"street": "Muncaster Rd",
"houseNumber": "831",
"city": "HAINES",
"coordinates": {
"latitude": 59.2442386,
"longitude": -135.4394579
}
}