Compare commits
3 Commits
329500f1ed
...
6f2c71891e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f2c71891e | ||
|
|
1730c2feaf | ||
|
|
d5daa80b02 |
10
.idea/.gitignore
generated
vendored
Normal file
10
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Ignored default folder with query files
|
||||||
|
/queries/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
7
.idea/misc.xml
generated
Normal file
7
.idea/misc.xml
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Black">
|
||||||
|
<option name="sdkName" value="Python 3.14" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.14 (toposhirt)" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/toposhirt.iml" filepath="$PROJECT_DIR$/.idea/toposhirt.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
10
.idea/toposhirt.iml
generated
Normal file
10
.idea/toposhirt.iml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.14 (toposhirt)" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -7,7 +7,32 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import time
|
import time
|
||||||
|
import pycountry
|
||||||
|
from country_bounding_boxes import country_subunits_by_iso_code
|
||||||
|
from country_iso2ify import get_resolver
|
||||||
|
|
||||||
|
resolver = get_resolver()
|
||||||
|
|
||||||
|
|
||||||
|
def get_mainland_bbox(country_name):
|
||||||
|
# Returns the main continental/primary bounding box
|
||||||
|
iso_code = resolver.resolve(country_name)
|
||||||
|
countries = country_subunits_by_iso_code(iso_code)
|
||||||
|
logging.debug("Country is [{}] iso code is [{}]".format(country_name,iso_code))
|
||||||
|
# The library is designed to return the main body of the country
|
||||||
|
# in the first result or by filtering for largest area.
|
||||||
|
item = None
|
||||||
|
if countries:
|
||||||
|
for item in countries:
|
||||||
|
logging.debug(item.subunit+str(item.bbox))
|
||||||
|
item = None
|
||||||
|
countries = country_subunits_by_iso_code(iso_code)
|
||||||
|
if countries:
|
||||||
|
for item in countries:
|
||||||
|
if item.subunit == country_name:
|
||||||
|
return item.bbox
|
||||||
|
return None
|
||||||
|
# foo
|
||||||
|
|
||||||
class Timerlog:
|
class Timerlog:
|
||||||
|
|
||||||
@ -60,7 +85,7 @@ parser.add_argument(
|
|||||||
"--country",
|
"--country",
|
||||||
dest='country',
|
dest='country',
|
||||||
metavar='country',
|
metavar='country',
|
||||||
default='United States',
|
default='US',
|
||||||
action='store',
|
action='store',
|
||||||
help="country to get topo image for")
|
help="country to get topo image for")
|
||||||
|
|
||||||
@ -101,4 +126,8 @@ logging.debug(t.end().report())
|
|||||||
logging.debug("Country is [{}]".format(args.country))
|
logging.debug("Country is [{}]".format(args.country))
|
||||||
logging.debug("Region is [{}]".format(args.region))
|
logging.debug("Region is [{}]".format(args.region))
|
||||||
|
|
||||||
|
iso_code = resolver.resolve(args.country)
|
||||||
|
logging.debug("iso_code for [{}] is [{}]".format(args.country, iso_code))
|
||||||
|
|
||||||
|
bbox=get_mainland_bbox(args.country)
|
||||||
|
logging.debug("BBOX is [{}]".format(bbox))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user