bjornd / jvectormap

jvectormap.com
GNU Affero General Public License v3.0
1.38k stars 431 forks source link

Get empty paths when use converter #461

Open t-walker-wei opened 4 years ago

t-walker-wei commented 4 years ago

Environment: Python 3.5.2 Ubuntu16.04LTS. The shp file I download from: http://www.naturalearthdata.com/ Json config file:

[{
    "name": "read_data",
    "file_name": "ne_110m_admin_0_countries_lakes/ne_110m_admin_0_countries_lakes.shp",
    "longitude0": 11.5
  },{
    "name": "write_data",
    "format": "jvectormap",
    "file_name": "origin-world.js",
    "params": {
      "code_field": "ISO_A2",
      "name_field": "NAME",
      "name": "world"
    }
  }]

Out put in origin-world.js : jQuery.fn.vectorMap('addMap', 'world_merc',{"height": 779.9122978262657, "projection": {"centralMeridian": 11.5, "type": "merc"}, "width": 900.0, "paths": {}, "insets": [{"height": 779.9122978262657, "bbox": [{"x": -20004297.15152583, "y": -18449355.690353}, {"x": 20026572.394749388, "y": 16240163.70055698}], "left": 0, "width": 900, "top": 0}]}); The paths attribute is empty. Do somebody have any ideas? Thx.

t-walker-wei commented 4 years ago

I should solved it.I flow the document and use script processor.py Change https://github.com/bjornd/jvectormap/blob/1a905c88ff2f19dc9ac01f6611a9ef3384a6049b/converter/processor.py#L13 to

from booleano.parser import Grammar, SymbolTable, Bind
from booleano.parser.core EvaluableParseManager

If have import EvaluableParseManager issue . For the empty paths issue, because the Python3 filter() / map() function return a filter object / map object instead of list. After iteration, the pointer will go the end of the object. My solution is convert the filter / map object to list. Example: After https://github.com/bjornd/jvectormap/blob/1a905c88ff2f19dc9ac01f6611a9ef3384a6049b/converter/processor.py#L163 add line: geometries = list(geometries)

t-walker-wei commented 4 years ago

And, I should try the converter.py.It would be better have document for how to use script converter.py