Skip to content
New issue

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

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

Already on GitHub? # to your account

Rearrange the package contents #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions examples/enaml_based/choropleth.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from enable.compiled_path import CompiledPath
from traits.api import HasTraits, Instance, List, Str

from mapping.enable.api import HTTPTileManager
from mapping.api import HTTPTileManager
from mapping.chaco.api import ChoroplethPlot

HERE = pth.dirname(__file__)
DATA_DIR = pth.join(pth.dirname(__file__), '..', 'data')


def create_colorbar(plt):
Expand Down Expand Up @@ -134,10 +134,10 @@ def _data_columns_default(self):
if __name__ == "__main__":
from mapping.enable.geojson_overlay import process_raw

population_filepath = pth.join(HERE, "..", "data", 'state_populations.csv')
population_filepath = pth.join(DATA_DIR, 'state_populations.csv')
populations = pandas.read_csv(population_filepath)

with open(pth.join(HERE, "states.geojs"), 'r') as fp:
with open(pth.join(DATA_DIR, 'states.geojs'), 'r') as fp:
polys = process_raw(fp.read().replace('\r\n', ''))
# generate compiled paths from polys
paths = []
Expand Down
10 changes: 5 additions & 5 deletions examples/enaml_based/counties.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from traits.api import HasTraits, Constant, Instance
from enable.tools.api import ViewportPanTool

from mapping.api import get_builtin_mbtiles_path
from mapping.enable.api import (MappingCanvas, MappingViewport, MBTileManager,
GeoJSONOverlay)
from mapping.api import get_builtin_mbtiles_path, MBTileManager
from mapping.chaco.api import GeoJSONOverlay
from mapping.enable.api import MappingCanvas, MappingViewport

HERE = pth.dirname(__file__)
DATA_DIR = pth.join(pth.dirname(__file__), '..', 'data')


class SingleMap(HasTraits):
Expand All @@ -27,7 +27,7 @@ def main():
min_level=2, max_level=4)

canvas = MappingCanvas(tile_cache=tile_layer)
counties_path = pth.join(HERE, 'counties.geojs')
counties_path = pth.join(DATA_DIR, 'counties.geojs')
canvas.overlays.append(GeoJSONOverlay(component=canvas,
geojs_filename=counties_path))

Expand Down
489 changes: 0 additions & 489 deletions examples/enaml_based/countries-hires.geojson

This file was deleted.

7 changes: 4 additions & 3 deletions examples/enaml_based/enthought_offices.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
from enable.tools.api import ViewportPanTool
from traits.api import HasTraits, Instance, Str, List, Tuple, Float

from mapping.enable.api import MappingCanvas, MappingViewport, HTTPTileManager
from mapping.api import HTTPTileManager
from mapping.enable.api import MappingCanvas, MappingViewport
from mapping.enable.primitives.api import GeoMarker

HERE = op.dirname(__file__)
DATA_DIR = op.join(op.dirname(__file__), '..', 'data')


class Office(HasTraits):
Expand Down Expand Up @@ -47,7 +48,7 @@ def add_office(self, city, location):
def _offices_changed(self, new):
viewports = []
canvas = self.canvas
marker_path = op.join(HERE, 'enthought-marker.png')
marker_path = op.join(DATA_DIR, 'enthought-marker.png')
for office in new:
canvas.add(GeoMarker(geoposition=office.location,
filename=marker_path))
Expand Down
4 changes: 2 additions & 2 deletions examples/enaml_based/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from enable.tools.api import ViewportPanTool
from traits.api import HasTraits, Instance, Str

from mapping.api import get_builtin_mbtiles_path
from mapping.enable.api import MappingCanvas, MappingViewport, MBTileManager
from mapping.api import get_builtin_mbtiles_path, MBTileManager
from mapping.enable.api import MappingCanvas, MappingViewport


class Model(HasTraits):
Expand Down
8 changes: 4 additions & 4 deletions examples/enaml_based/local_with_marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from enable.tools.api import ViewportPanTool
from traits.api import HasTraits, Instance, Constant, Str

from mapping.api import get_builtin_mbtiles_path
from mapping.enable.api import MappingCanvas, MappingViewport, MBTileManager
from mapping.api import get_builtin_mbtiles_path, MBTileManager
from mapping.enable.api import MappingCanvas, MappingViewport
from mapping.enable.primitives.api import GeoMarker

HERE = pth.dirname(__file__)
DATA_DIR = pth.join(pth.dirname(__file__), '..', 'data')


class Model(HasTraits):
Expand All @@ -29,7 +29,7 @@ def main():

canvas = MappingCanvas(tile_cache=tile_layer)

marker_path = pth.join(HERE, 'enthought-marker.png')
marker_path = pth.join(DATA_DIR, 'enthought-marker.png')
canvas.add(GeoMarker(filename=marker_path,
geoposition=(40.7546423, -73.9748948)))

Expand Down
10 changes: 5 additions & 5 deletions examples/enaml_based/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from traits.api import HasTraits, Constant, Instance
from enable.tools.api import ViewportPanTool

from mapping.api import get_builtin_mbtiles_path
from mapping.enable.api import (MappingCanvas, MappingViewport, MBTileManager,
GeoJSONOverlay)
from mapping.api import get_builtin_mbtiles_path, MBTileManager
from mapping.chaco.api import GeoJSONOverlay
from mapping.enable.api import MappingCanvas, MappingViewport

HERE = pth.dirname(__file__)
DATA_DIR = pth.join(pth.dirname(__file__), '..', 'data')


class SingleMap(HasTraits):
Expand All @@ -27,7 +27,7 @@ def main():
min_level=2, max_level=4)

canvas = MappingCanvas(tile_cache=tile_layer)
states_path = pth.join(HERE, 'states.geojs')
states_path = pth.join(DATA_DIR, 'states.geojs')
canvas.overlays.append(GeoJSONOverlay(component=canvas,
geojs_filename=states_path))

Expand Down
3 changes: 2 additions & 1 deletion examples/enaml_based/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from enable.tools.api import ViewportPanTool
from traits.api import HasTraits, Instance, Str, Dict

from mapping.enable.api import MappingCanvas, MappingViewport, HTTPTileManager
from mapping.api import HTTPTileManager
from mapping.enable.api import MappingCanvas, MappingViewport
from mapping.enable.primitives.api import GeoCircle

SERVERS = {
Expand Down
10 changes: 5 additions & 5 deletions examples/enaml_based/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from enable.tools.api import ViewportPanTool
from traits.api import HasTraits, Constant, Instance

from mapping.api import get_builtin_mbtiles_path
from mapping.enable.api import (MappingCanvas, MappingViewport, MBTileManager,
GeoJSONOverlay)
from mapping.api import get_builtin_mbtiles_path, MBTileManager
from mapping.chaco.api import GeoJSONOverlay
from mapping.enable.api import MappingCanvas, MappingViewport

HERE = pth.dirname(__file__)
DATA_DIR = pth.join(pth.dirname(__file__), '..', 'data')


class SingleMap(HasTraits):
Expand All @@ -27,7 +27,7 @@ def main():
min_level=2, max_level=4)

canvas = MappingCanvas(tile_cache=tile_layer)
world_path = pth.join(HERE, 'world.geojs')
world_path = pth.join(DATA_DIR, 'world.geojs')
canvas.overlays.append(GeoJSONOverlay(component=canvas,
geojs_filename=world_path))

Expand Down
11 changes: 5 additions & 6 deletions examples/traitsui_based/chaco_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
from traits.api import HasTraits, Constant, Instance
from traitsui.api import View, UItem

from mapping.api import get_builtin_mbtiles_path
from mapping.enable.mbtile_manager import MBTileManager
from mapping.chaco.map import Map
from mapping.api import get_builtin_mbtiles_path, MBTileManager
from mapping.chaco.api import Map

HERE = pth.dirname(__file__)
DATA_DIR = pth.join(pth.dirname(__file__), '..', 'data')


def create_colorbar(colormap):
Expand All @@ -36,14 +35,14 @@ def create_colorbar(colormap):

def _create_plot_component():
# Load state data
states_filepath = pth.join(HERE, "..", "data", 'states.csv')
states_filepath = pth.join(DATA_DIR, 'states.csv')
states = pandas.read_csv(states_filepath)
lon = (states['longitude'] + 180.) / 360.
lat = numpy.radians(states['latitude'])
lat = (1 - (1. - numpy.log(numpy.tan(lat) +
(1./numpy.cos(lat)))/numpy.pi)/2.0)

population_filepath = pth.join(HERE, "..", "data", 'state_populations.csv')
population_filepath = pth.join(DATA_DIR, 'state_populations.csv')
populations = pandas.read_csv(population_filepath)
data = populations['2010']
lon = lon.view(numpy.ndarray)
Expand Down
1 change: 0 additions & 1 deletion examples/traitsui_based/counties.geojs

This file was deleted.

11 changes: 6 additions & 5 deletions examples/traitsui_based/counties.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
from traits.api import HasTraits, Instance
from traitsui.api import Item, ModelView, View

from mapping.api import get_builtin_mbtiles_path
from mapping.enable.api import (MappingCanvas, MappingViewport, MBTileManager,
GeoJSONOverlay)
from mapping.api import get_builtin_mbtiles_path, MBTileManager
from mapping.chaco.api import GeoJSONOverlay
from mapping.enable.api import MappingCanvas, MappingViewport

HERE = pth.dirname(__file__)
DATA_DIR = pth.join(pth.dirname(__file__), '..', 'data')


class SingleMap(HasTraits):
Expand All @@ -38,9 +38,10 @@ def main():
tile_layer = MBTileManager(filename=get_builtin_mbtiles_path(),
min_level=2, max_level=4)

counties_path = pth.join(DATA_DIR, 'counties.geojs')
canvas = MappingCanvas(tile_cache=tile_layer)
canvas.overlays.append(GeoJSONOverlay(component=canvas,
geojs_filename='counties.geojs'))
geojs_filename=counties_path))

viewport = MappingViewport(component=canvas, zoom_level=2,
geoposition=(37.09024, -95.712891))
Expand Down
5 changes: 2 additions & 3 deletions examples/traitsui_based/img_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
add_default_axes, add_default_grids)
from chaco.tools.api import PanTool, ZoomTool

from mapping.chaco.map import Map
from mapping.chaco.null_renderer import NullPlotRenderer
from mapping.enable.img_tile_manager import ImageTileManager
from mapping.api import ImageTileManager
from mapping.chaco.api import Map, NullPlotRenderer


def build_formatter(maxval, flip=False):
Expand Down
3 changes: 2 additions & 1 deletion examples/traitsui_based/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from traits.api import HasTraits, Instance, Str, Dict
from traitsui.api import Item, View

from mapping.enable.api import MappingCanvas, MappingViewport, HTTPTileManager
from mapping.api import HTTPTileManager
from mapping.enable.api import MappingCanvas, MappingViewport
from mapping.enable.primitives.api import GeoCircle

SERVERS = {
Expand Down
6 changes: 5 additions & 1 deletion mapping/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# flake8: noqa

from .async_loader import AsyncRequest, get_global_async_loader
from .cacheing_decorators import lfu_cache, lru_cache
from .http_tile_manager import HTTPTileManager
from .img_tile_manager import ImageTileManager
from .mbtile_manager import MBTileManager
from .utils import get_builtin_mbtiles_path
2 changes: 1 addition & 1 deletion mapping/enable/async_loader.py → mapping/async_loader.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from abc import ABCMeta, abstractmethod
from threading import Event, Thread

from six.moves import queue
from six import with_metaclass
from six.moves import queue

from traits.api import HasTraits, Any, Instance

Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions mapping/chaco/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# flake8: noqa
from .choropleth_plot import ChoroplethPlot
try:
from .geojson_overlay import GeoJSONOverlay
except ImportError:
pass # No geojson
from .map import Map
from .null_renderer import NullPlotRenderer
2 changes: 1 addition & 1 deletion mapping/chaco/choropleth_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from kiva.constants import FILL_STROKE
from traits.api import Instance, List, DelegatesTo, Array

from mapping.chaco.map import Map
from .map import Map


class ChoroplethPlot(ColormappedScatterPlot):
Expand Down
File renamed without changes.
10 changes: 1 addition & 9 deletions mapping/enable/api.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# flake8: noqa
from .canvas import MappingCanvas
from .viewport import MappingViewport
try:
from .geojson_overlay import GeoJSONOverlay
except ImportError:
# No geojson
pass

# Tile managers
from .mbtile_manager import MBTileManager
from .http_tile_manager import HTTPTileManager
from .zoom import MappingZoomTool
6 changes: 3 additions & 3 deletions mapping/enable/canvas.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from __future__ import print_function

import math
from io import BytesIO
import math

from enable.api import Canvas, ColorTrait
from kiva.image import Image
from kiva.constants import FILL
from kiva.image import Image
from traits.api import Int, Range, Instance, on_trait_change

from .i_tile_manager import ITileManager
from mapping.i_tile_manager import ITileManager


class MappingCanvas(Canvas):
Expand Down
2 changes: 1 addition & 1 deletion mapping/enable/primitives/geo_primitive.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enable.primitives.shape import Shape
from enable.enable_traits import coordinate_trait
from enable.primitives.shape import Shape
from traits.api import Property, Bool, property_depends_on


Expand Down
12 changes: 5 additions & 7 deletions mapping/enable/tests/test_canvas.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
from unittest import TestCase
import unittest

from kiva.image import Image

from mapping.api import get_builtin_mbtiles_path
from mapping.enable.canvas import MappingCanvas
from mapping.enable.api import MBTileManager
from mapping.api import MBTileManager, get_builtin_mbtiles_path
from mapping.enable.api import MappingCanvas


class TestMappingCanvas(TestCase):
class TestMappingCanvas(unittest.TestCase):
def setUp(self):
tile_layer = MBTileManager(filename=get_builtin_mbtiles_path(),
min_level=2, max_level=4)

self.canvas = MappingCanvas(tile_cache=tile_layer)

def test__blank_tile(self):
def test_blank_tile(self):
self.assertIsInstance(self.canvas._blank_tile, Image)
2 changes: 1 addition & 1 deletion mapping/enable/viewport.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

from numpy import array

from enable.viewport import Viewport
from enable.base import empty_rectangle, intersect_bounds
from enable.viewport import Viewport
from traits.api import (
Instance, Bool, CList, Int, Property, Float, DelegatesTo, NO_COMPARE
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

import requests

from traits.api import Int, Str, on_trait_change, Instance, provides
from pyface.gui import GUI
from traits.api import Int, Str, on_trait_change, Instance, provides

from .async_loader import AsyncLoader, AsyncRequest, get_global_async_loader
from .cacheing_decorators import lru_cache
from .i_tile_manager import ITileManager
from .tile_manager import TileManager
from .cacheing_decorators import lru_cache
from .async_loader import AsyncLoader, AsyncRequest, get_global_async_loader


@provides(ITileManager)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

from traits.api import Instance, Str, provides

from .i_tile_manager import ITileManager
from .tile_manager import TileManager
from .cacheing_decorators import lru_cache
from .i_tile_manager import ITileManager
from .mbtiles import MbtileSet
from .tile_manager import TileManager


@provides(ITileManager)
Expand Down
Loading