forked from fraunhoferfokus/ogd-metadata
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request fraunhoferfokus#2 from eue/master
Kategorien-Zuordnungen von ISO191xx Python-Hilfsfunktions zum Übertragen der Kategorien
- Loading branch information
Showing
11 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"farming": ["wirtschaft_arbeit"], | ||
"biota": ["umwelt_klima"], | ||
"boundaries": ["geografie"], | ||
"climatologyMeteorologyAtmosphere": ["umwelt_klima"], | ||
"economy": ["wirtschaft_arbeit"], | ||
"elevation": ["geo"], | ||
"environment": ["umwelt_klima"], | ||
"geoscientificInformation": ["geo"], | ||
"health": ["gesundheit"], | ||
"imageryBaseMapsEarthCover": ["geo"], | ||
"location": ["geografie"], | ||
"oceans": ["geo"], | ||
"planningCadastre": ["geografie"], | ||
"society": ["Demographie"], | ||
"structure": ["stadtplanung"], | ||
"transportation": ["transport_verkehr"], | ||
"utilitiesCommunication": ["infrastruktur_bauen_wohnen"], | ||
"inlandWaters": ["geo"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import json, urllib2 | ||
|
||
class Util: | ||
|
||
def translate(self, categories, sourceportal): | ||
url = "https://github.com/fraunhoferfokus/ogd-metadata/raw/master/kategorien/" + sourceportal + "2deutschland.json" | ||
map = json.loads( urllib2.urlopen(url).read()) | ||
out = [] | ||
for cat in categories: | ||
if cat in map.keys(): | ||
out = out + map[cat] | ||
return out | ||
|
||
|
||
import unittest | ||
class TestMapping(unittest.TestCase): | ||
|
||
|
||
def test_b2d(self): | ||
u = Util() | ||
translated = u.translate(['verkehr','wahl'], 'berlin') | ||
print translated | ||
self.assertEqual(translated, ['transport_verkehr','politik_wahlen']) | ||
|
||
def test_missing(self): | ||
u = Util() | ||
translated = u.translate(['verkehr','xyz','wahl'], 'berlin') | ||
print translated | ||
self.assertEqual(translated, ['transport_verkehr','politik_wahlen']) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|
Empty file.
Empty file.