Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render GeoJSON Default #51

Merged
merged 4 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions openaddr/process_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def boolstr(value):
raise ValueError(repr(value))

def process(source, destination, layer, layersource,
do_geojsonld, do_preview, do_mbtiles, do_pmtiles,
do_preview, do_mbtiles, do_pmtiles,
mapbox_key=None, extras=dict()):
''' Process a single source and destination, return path to JSON state file.

Expand Down Expand Up @@ -163,13 +163,12 @@ def process(source, destination, layer, layersource,
else:
_L.info('Preview image in {}'.format(preview_path))

if do_geojsonld:
geojsonld_path = render_geojsonld(conform_result.path, temp_dir)
geojsonld_path = render_geojsonld(conform_result.path, temp_dir)

if not geojsonld_path:
_L.warning('No GeoJSON-LD generated')
else:
_L.info('GeoJSON-LD file in {}'.format(geojsonld_path))
if not geojsonld_path:
_L.warning('No GeoJSON-LD generated')
else:
_L.info('GeoJSON-LD file in {}'.format(geojsonld_path))

if do_mbtiles:
if not geojsonld_path:
Expand Down Expand Up @@ -475,13 +474,13 @@ def write_state(source, layer, data_source_name, skipped, destination, log_handl
parser.add_argument('-ls', '--layersource', help='Source within a given layer to pull from',
dest='layersource', default='')

parser.add_argument('--skip-geojsonld', help="Don't generate GeoJSON-LD alongside CSV output",
action='store_const', dest='generate_geojsonld',
const=False, default=False)

parser.add_argument('--skip-preview', help="Don't render a map preview",
action='store_const', dest='render_preview',
const=False, default=False)
const=False, default=True)

parser.add_argument('--render-preview', help="Render a map preview",
action='store_const', dest='render_preview',
const=True, default=True)

parser.add_argument('--mapbox-key', dest='mapbox_key',
help='Mapbox API Key. See: https://mapbox.com/')
Expand Down Expand Up @@ -524,18 +523,12 @@ def main():
_L.error('Mapbox key is required to generate preview')
return 1

# Can't generate preview without GeoJSON-LD
if args.render_preview and not args.generate_geojsonld:
_L.error('GeoJSON-LD is required to generate preview')
return 1

# Allow CSV files with very long fields
csv.field_size_limit(sys.maxsize)

try:
processed_path = process(args.source, args.destination,
args.layer, args.layersource,
args.generate_geojsonld,
args.render_preview,
args.render_preview,
args.render_preview,
Expand Down
Loading