Metadata-Version: 2.0
Name: tsp-rest-api-server
Version: 3.5
Summary: TSP Rest Api Server - Rest Api Server using Dijsktra's algorithm applied to travelling salesman problem.
Home-page: https://github.com/caputomarcos/tsp-rest-api-server
Author: Marcos Caputo <caputo.marcos@gmail.com>
Author-email: UNKNOWN
License: MIT
Description-Content-Type: UNKNOWN
Platform: UNKNOWN
Classifier: Framework :: Flask
Classifier: Programming Language :: Python
Requires-Dist: click (==6.7)
Requires-Dist: Eve (==0.7.4)
Requires-Dist: Events (==0.2.2)
Requires-Dist: flask (<=0.12,>=0.10.1)
Requires-Dist: Flask-PyMongo (==0.5.1)
Requires-Dist: itsdangerous (==0.24)
Requires-Dist: Jinja2 (==2.9.6)
Requires-Dist: MarkupSafe (==0.23)
Requires-Dist: simplejson (==3.11.1)
Requires-Dist: Werkzeug (==0.11.15)
Provides-Extra: dev
Requires-Dist: click (==6.7); extra == 'dev'
Requires-Dist: Eve (==0.7.4); extra == 'dev'
Requires-Dist: Events (==0.2.2); extra == 'dev'
Requires-Dist: flask (<=0.12,>=0.10.1); extra == 'dev'
Requires-Dist: Flask-PyMongo (==0.5.1); extra == 'dev'
Requires-Dist: itsdangerous (==0.24); extra == 'dev'
Requires-Dist: Jinja2 (==2.9.6); extra == 'dev'
Requires-Dist: MarkupSafe (==0.23); extra == 'dev'
Requires-Dist: simplejson (==3.11.1); extra == 'dev'
Requires-Dist: Werkzeug (==0.11.15); extra == 'dev'
Requires-Dist: mock (==2.0.0); extra == 'dev'
Provides-Extra: mongo
Requires-Dist: click (==6.7); extra == 'mongo'
Requires-Dist: Eve (==0.7.4); extra == 'mongo'
Requires-Dist: Events (==0.2.2); extra == 'mongo'
Requires-Dist: flask (<=0.12,>=0.10.1); extra == 'mongo'
Requires-Dist: Flask-PyMongo (==0.5.1); extra == 'mongo'
Requires-Dist: itsdangerous (==0.24); extra == 'mongo'
Requires-Dist: Jinja2 (==2.9.6); extra == 'mongo'
Requires-Dist: MarkupSafe (==0.23); extra == 'mongo'
Requires-Dist: simplejson (==3.11.1); extra == 'mongo'
Requires-Dist: Werkzeug (==0.11.15); extra == 'mongo'
Requires-Dist: pymongo (==3.5.1); extra == 'mongo'

.. image:: https://raw.githubusercontent.com/caputomarcos/tsp-rest-api-server/master/logotipo-pickngo.png



tsp-rest-api-server
===================


TSP Rest Api Server - Rest Api Server using Dijsktra's algorithm applied to travelling salesman problem.


License
-------
Licensed under the MIT License.


Install
-------

Follow the steps below to get everything up and running.


pip
---


1. Create project folder:

   .. code-block:: bash

        $ mkdir tsp-rest-api-server && cd tsp-rest-api-server

2. Create virtualenv in the normal way:

   .. code-block:: bash

        $ virtualenv env --python=python

3. Active your new virtualenv:

   .. code-block:: bash

        $ source env/bin/activate


4. Install tsp-rest-api-server:

   .. code-block:: bash

        $ pip install tsp-rest-api-server


5. Create setting file:

   .. code-block:: bash

        $ tsp_rest_api_server settings

6. Set EVE_SETTINGS:

   .. code-block:: bash

        $ export EVE_SETTINGS=$PWD/settings.py

7. Run tsp rest api server:

   .. code-block:: bash

        $ tsp_rest_api_server runserver



Git
----

1. Clone repository:

   .. code-block:: bash

        $ git clone git@github.com:caputomarcos/tsp_rest_api_server.git

2. Go to tsp_rest_api_server source folder:

   .. code-block:: bash

        $ cd tsp-rest-api-server/

3. Create virtualenv in the normal way:

   .. code-block:: bash

        $ virtualenv env --python=python

4. Active your new virtualenv:

   .. code-block:: bash

        $ source env/bin/activate


5. Create dev environment:

   .. code-block:: bash

        $ make develop


Usage
------

1. Create routes:

   .. code-block:: bash

        $ curl -d "@map.json"  -H "Content-Type: application/json" -X POST http://0.0.0.0:5000/maps

        or

        $ curl -d '{ "title":"Sao Paulo", "routes":[{"origin":"A","destiny":"B","distance":10},{"origin":"B","destiny":"D","distance":15},{"origin":"A","destiny":"C","distance":20},{"origin":"C","destiny":"D","distance":30},{"origin":"B","destiny":"E","distance":50},{"origin":"D","destiny":"E","distance":30}]}' -H "Content-Type: application/json" -X POST http://0.0.0.0:5000/maps


3. Search shortest route:

   .. code-block:: bash

        $ curl 'http://0.0.0.0:5000/maps/shortest?map=Sao%20Paulo&origin=A&destiny=D&price=2.50&autonomy=10'

        {
          "data": [
            {
              "Path": "['A', 'B', 'D']"
            },
            {
              "Total KM": "25.00"
            },
            {
              "Cost": "6.25"
            }
          ]
        }


Drop all mongodb databases
--------------------------

   .. code-block:: JavaScript

        # dropall.js

        var dbs = db.getMongo().getDBNames()
        for(var i in dbs){
            db = db.getMongo().getDB( dbs[i] );
            print( "dropping db " + db.getName() );
            db.dropDatabase();
        }


usage
-----

   .. code-block:: bash

        mongo dropall.js

refs
----

* `DIJKSTRA'S SHORTEST PATH ALGORITHM  <http://www.bogotobogo.com/python/python_Dijkstras_Shortest_Path_Algorithm.php>`_




