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

Doesn't recognize WKT MultiLineString type #22

Open
tschomay opened this issue Apr 24, 2020 · 1 comment
Open

Doesn't recognize WKT MultiLineString type #22

tschomay opened this issue Apr 24, 2020 · 1 comment

Comments

@tschomay
Copy link

Theto throws an error when attempting to plot a MultiLineString well known text data type. MWE below:

wkts = ['MULTILINESTRING ((0 0, 1 1), (2 0, 2 1))']
(
    Theto(api_key=None)
    .add_source(wkts, label='a')
    .prepare_plot(plot_width=400, map_type='carto_light')
    .add_layer('a', fill_color='yellow', line_color='black', alpha=0.5)
    .render_plot('notebook')
)

The following error is produced:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-07450c06b8a0> in <module>
      5 (
      6     Theto(api_key=None)
----> 7     .add_source(wkts, label='a')
      8     .prepare_plot(plot_width=400, map_type='carto_light')
      9     .add_layer('a', fill_color='yellow', line_color='black', alpha=0.5)

/opt/maxpoint/envs/analysis-preview-py3-115.0-5968/lib/python3.6/site-packages/theto/theto.py in add_source(self, data, label, uid, column_name, **kwargs)
    256             processed_data = [coordinate_utils.import_geojson(v, self.precision) for v in raw_data]
    257         else:
--> 258             processed_data = [coordinate_utils.process_input_value(v) for v in raw_data]
    259 
    260         processed_data_transformed = [coordinate_utils.to_webmercator(v) for v in processed_data]

/opt/maxpoint/envs/analysis-preview-py3-115.0-5968/lib/python3.6/site-packages/theto/theto.py in <listcomp>(.0)
    256             processed_data = [coordinate_utils.import_geojson(v, self.precision) for v in raw_data]
    257         else:
--> 258             processed_data = [coordinate_utils.process_input_value(v) for v in raw_data]
    259 
    260         processed_data_transformed = [coordinate_utils.to_webmercator(v) for v in processed_data]

/opt/maxpoint/envs/analysis-preview-py3-115.0-5968/lib/python3.6/site-packages/theto/coordinate_utils.py in process_input_value(value)
    288             return loads(value)
    289         else:
--> 290             raise ValueError('String inputs must be either a geohash or well-known text.')
    291     elif type(value) in (tuple, list):
    292         if validate_latlon_pair(value):

ValueError: String inputs must be either a geohash or well-known text.
@schaunwheeler
Copy link
Contributor

There's a typo in Theto.coordinate_utils:

VALID_WKT_TYPES = [
    'GEOMETRY', 
    'POINT', 
    'MULTIPOINT', 
    'LINESTRING',
    'LINEARRING'
    'MULTILINESTRING', 
    'POLYGON', 
    'MULTIPOLYGON'
]

There's a comma missing after 'LINEARRING'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants