Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blackboxlogic/osmtagstranslator
Do you need to convert third party data into OpenStreetMap tags, but your object oriented language is clunky? This tool lets you express OSM tag transformations as SQLite queries.
https://github.com/blackboxlogic/osmtagstranslator
openstreetmap openstreetmap-data openstreetmap-tags
Last synced: about 1 month ago
JSON representation
Do you need to convert third party data into OpenStreetMap tags, but your object oriented language is clunky? This tool lets you express OSM tag transformations as SQLite queries.
- Host: GitHub
- URL: https://github.com/blackboxlogic/osmtagstranslator
- Owner: blackboxlogic
- License: mit
- Created: 2020-06-10T15:06:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-02-15T17:21:58.000Z (10 months ago)
- Last Synced: 2024-11-08T23:58:35.170Z (about 1 month ago)
- Topics: openstreetmap, openstreetmap-data, openstreetmap-tags
- Language: C#
- Homepage:
- Size: 1.1 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OsmTagsTranslator
## Do you need to convert third party data into OpenStreetMap tags, but your object oriented language is clunky? This tool lets you express OSM tag transformations as SQLite queries.[This file](https://github.com/blackboxlogic/OsmTagsTranslator/blob/master/OsmTagsTranslator.Tests/SampleE911Addresses.osm) has the address fields from Maine's department of transportation. These tags are not suitable for OSM :unamused:
```xml
...
...```
Each tag needs some work. For example, `addr:street=East Lillian Place` must be composed from { `PREDIR=E`, `STREETNAME=Lillian`, `SUFFIX=Pl`}. We can express these transformations using a [SQLite query](https://github.com/blackboxlogic/OsmTagsTranslator/blob/master/OsmTagsTranslator/Queries/E911AddressesToOsmSchema.sql) :open_mouth:
```sql
SELECT
-- These first two columns are required to identify elements
xid,
xtype,
-- Every other column becomes a tag
ADDRESS_NUMBER as [addr:housenumber],
-- Some tags just need their key changed
UNIT as [addr:unit],
-- Other tags need lookups and string manipulation
COALESCE(pre.Value || ' ', '')
|| COALESCE(STREETNAME, '')
|| COALESCE(' ' || suf.Value, '')
|| COALESCE(' ' || post.Value, '') as [addr:street],
POSTAL_COMMUNITY as [addr:city],
STATE as [addr:state],
ZIPCODE as [addr:postcode],
-- Null or empty fields don't become tags
LANDMARK as [name],
-- Arbitrary tags can be added from more complicated lookup tables
moreDetails.*
FROM Elements
-- Lookup are case-insensitive
LEFT JOIN Directions as pre
ON pre.ID = PREDIR
LEFT JOIN Directions as post
ON post.ID = POSTDIR
LEFT JOIN StreetSuffixes as suf
ON suf.ID = SUFFIX
LEFT JOIN PlaceTypes as moreDetails
ON moreDetails.ID = PLACE_TYPE
-- Filter too, if you'd like. Those elements won't be in the result
WHERE ADDRESS_NUMBER != '0'
```JSON files can be loaded as tables with columns "ID" and "Value", like [this one](https://github.com/blackboxlogic/OsmTagsTranslator/blob/master/OsmTagsTranslator/Lookups/StreetSuffixes.json), which expands `SUFFIX=Pl` into `Place` :relieved:
```javascript
{
...
"PIKES": "Pike",
"PINE": "Pine",
"PINES": "Pines",
"PNES": "Pines",
"PL": "Place",
"PLAIN": "Plain",
"PLN": "Plain",
"PLAINS": "Plains",
...
}
```
Provide as many lookup files as needed, like one to convert ["E" to "East"](https://github.com/blackboxlogic/OsmTagsTranslator/blob/master/OsmTagsTranslator/Lookups/Directions.json) or [add arbitrary other tags](https://github.com/blackboxlogic/OsmTagsTranslator/blob/master/OsmTagsTranslator/Lookups/PlaceTypes.json).Run `> OsmTagsTranslatorConsole.exe SampleE911Addresses.osm Lookups\Directions.json Lookups\StreetSuffixes.json Lookups\PlaceTypes.json Quieries\E911AddressesToOsmSchema.sql`
The [resulting file](https://github.com/blackboxlogic/OsmTagsTranslator/blob/master/OsmTagsTranslator.Tests/E911AddressesToOsmSchema.sql%2BSampleE911Addresses.osm) is transformed into OSM conformant tags! :mage::tophat::rabbit2:
```xml
...```
This project is an executable, interactive command line tool, and a [nuget package](https://www.nuget.org/packages/OsmTagsTranslator/). Running in a command prompt without a sql script like `> OsmTagsTranslatorConsole.exe SampleE911Addresses.osm` lets you do data analysis, for example:
```SQL
SELECT POSTAL_COMMUNITY, count(1) FROM Elements GROUP BY POSTAL_COMMUNITY ORDER BY 2 DESC
```