#!/usr/bin/python
"""
Script to produce GeoJSON from HXL

David Megginson
November 2014

Usage:

  hxl2geojson < DATA_IN.csv > DATA_OUT.json

(For full usage information, use the -h option.)

Creates point data only. The script can handle extremely long
datasets, because it does not try to hold the entire dataset in memory
at once.

License: Public Domain
Documentation: http://hxlstandard.org
"""

import sys
import argparse
from hxl.filters.hxl2geojson import hxl2geojson

# Command-line arguments
parser = argparse.ArgumentParser(description = 'Convert a HXL dataset to GeoJSON points.')
parser.add_argument(
    'infile',
    help='HXL file to read (if omitted, use standard input).',
    nargs='?',
    type=argparse.FileType('r'),
    default=sys.stdin
    )
parser.add_argument(
    'outfile',
    help='HXL file to write (if omitted, use standard output).',
    nargs='?',
    type=argparse.FileType('w'),
    default=sys.stdout
    )
args = parser.parse_args()

# Call the command function
hxl2geojson(input=args.infile, output=args.outfile)

# end
