mapbox / tilelive-omnivore

Implements the tilelive api for a variety of data sources
ISC License
8 stars 11 forks source link

Add command line tool: given a file, generate xml #18

Closed springmeyer closed 8 years ago

springmeyer commented 9 years ago

/cc @rclark @GretaCB

Just found myself in need of this. Does this seem like a nice addition? Or does it duplicate functionality somewhere else that I might have missed?

Idea is to quickly generate the XML tilelive-copy + tilelive-bridge needs on the command line. This is useful when you want to hand edit the XML later on to adjust the export settings for debugging.

$ node bin/generate_xml.js ~/data/box.json
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" maximum-extent="-20037508.34,-20037508.34,20037508.34,20037508.34">
  <Parameters>
    <Parameter name="center">-101.6015625,42.72699658492618,0</Parameter>
    <Parameter name="bounds">-159.609375,9.102096738726456,-43.59375,76.3518964311259</Parameter>
    <Parameter name="format">pbf</Parameter>
    <Parameter name="json"><![CDATA[{"vector_layers":[{"id":"box","description":"","minzoom":0,"maxzoom":22,"fields":{"application_count_all_chemical":"Number","application_count_fumigants":"Number","id":"Number","top_chemicals":"String","total_lbs_used_all_chemical":"Number","total_lbs_used_fumigants_chemical":"Number"}}]}]]></Parameter>
    <Parameter name="maxzoom">2</Parameter>
    <Parameter name="minzoom">0</Parameter>
  </Parameters>

  <Layer name="box" buffer-size="8" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">

    <Datasource>
      <Parameter name="type">geojson</Parameter>
      <Parameter name="file">/Users/dane/data/box.json</Parameter>
      <Parameter name="layer">box</Parameter>
      <Parameter name="cache_features">false</Parameter>
    </Datasource>
  </Layer>

</Map>
rclark commented 9 years ago

I think this'd be a good addition. Could you add it to package.json and maybe write a simple test about asserting that it handles CLI args properly?

GretaCB commented 9 years ago

Great idea Dane :+1:

yhahn commented 9 years ago

This command needs a nicer name, like maybe just mapnik-omnivore <filepath> :smile:

mapsam commented 8 years ago

Renamed to mapnik-omnivore and tests added in test/index.js to handle CLI arguments. Ready to :rocket:

cc/ @springmeyer @rclark @GretaCB @yhahn

springmeyer commented 8 years ago

Awesome thanks !!!! @mapsam. Want to close this and land things in https://github.com/mapbox/tilelive-omnivore/pull/25 (as I see you pulled things into that branch :+1:) ?

mapsam commented 8 years ago

Closing in favor of #25!