attempt to re-create mobilitydb-sqlalchemy-demo on ilc

Python3.7

had to go back and re-build python with --enable-shared !!!

postgresql

MUST be V11 !!!!!!!!

d/l and install (locally) latest postgresql:

    $ wget https://ftp.postgresql.org/pub/source/v11.7/postgresql-11.7.tar.bz2
    $ tar jxvf postgresql-11.7.tar.bz2
    $ export PYTHON=/home/wendell/usr/local/bin/python3.7
    $ export  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/wendell/usr/local/lib/
not sure if that helped...

    $ ./configure --prefix=/home/wendell/usr/local --with-python
    $ make
    $ make install

continuing...

postgis

    $ wget https://download.osgeo.org/postgis/source/postgis-2.5.4.tar.gz
    $ tar zxvf postgis-2.5.4.tar.gz
    $ cd postgis-2.5.4
    $ ./configure --prefix=/home/wendell/usr/local
    $ ./configure --prefix=/home/wendell/usr/local --with-python --with-jsondir=/home/wendell/usr/local

config.status: executing po-directories commands

  PostGIS is now configured for x86_64-unknown-linux-gnu

 -------------- Compiler Info -------------
  C compiler:           gcc -g -O2
  SQL preprocessor:     /usr/bin/cpp -traditional-cpp -w -P

 -------------- Additional Info -------------
  Interrupt Tests:   DISABLED use: --with-interrupt-tests to enable

 -------------- Dependencies --------------
  GEOS config:          /usr/bin/geos-config
  GEOS version:         3.5.0
  GDAL config:          /home/wendell/usr/local/bin/gdal-config
  GDAL version:         2.4.2
  PostgreSQL config:    /home/wendell/usr/local/bin/pg_config
  PostgreSQL version:   PostgreSQL 11.7
  PROJ4 version:        48
  Libxml2 config:       /usr/bin/xml2-config
  Libxml2 version:      2.9.1
  JSON-C support:       yes
  protobuf-c support:   no
  PCRE support:         yes
  Perl:                 /usr/bin/perl

 --------------- Extensions ---------------
  PostGIS Raster:       enabled
  PostGIS Topology:     enabled
  SFCGAL support:       disabled
  Address Standardizer support:       enabled

 -------- Documentation Generation --------
  xsltproc:             /usr/bin/xsltproc
  xsl style sheets:
  dblatex:
  convert:              /usr/bin/convert
  mathml2.dtd:          http://www.w3.org/Math/DTD/mathml2/mathml2.dtd

configure: WARNING:  --------- GEOS VERSION WARNING ------------
configure: WARNING:   You are building against GEOS 3.5.0
configure: WARNING:   To take advantage of all the features of
configure: WARNING:   this PostGIS version requires GEOS 3.7.0 or higher.
configure: WARNING:   To take advantage of most of the features of this PostGIS
configure: WARNING:   we recommend GEOS 3.6 or higher
configure: WARNING:   You can download the latest versions from
configure: WARNING:   http://trac.osgeo.org/geos
configure: WARNING:

CONSIDER: OLD GEOS warning

    $ make install

make[1]: Entering directory `/home/wendell/pkgs/postgis-2.5.4/liblwgeom'
/usr/bin/install -c -d "/home/data/local/lib"
/usr/bin/install: cannot create directory ‘/home/data’: Permission denied
make[1]: *** [install-liblwgeom] Error 1
make[1]: Leaving directory `/home/wendell/pkgs/postgis-2.5.4/liblwgeom'
make: *** [install] Error 1

now just guessing...

    $ make DESTDIR=/home/wendell/usr/local install
AND ALSO:
    $ make install

???

seems to have completed with no errors...

configure and start postgresql

    $ cd ~/usr/local
    $ mkdir databases
    $ cd databases
    $ mkdir pgsql_data

    $ export PGSQL_VERSION=11
    $ export PGDATA="/home/wendell/usr/local/databases/pgsql_data"
    $ ~/usr/local/bin/initdb

The files belonging to this database system will be owned by user "wendell".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /home/wendell/usr/local/databases/pgsql_data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /home/wendell/usr/local/bin/pg_ctl -D /home/wendell/usr/local/databases/pgsql_data -l logfile start

looks good...

    $ cd /home/wendell/usr/local/databases/pgsql_data
    $ vim postgresql.conf

        port = 55432                            # (change requires restart)

    $ cd /home/wendell/usr/local/databases/

    $ /home/wendell/usr/local/bin/pg_ctl -D /home/wendell/usr/local/databases/pgsql_data -l logfile start
    waiting for server to start.... done
    server started

looks ok so far...

    $ createdb -p 55432  firstdb
    $ psql -p 55432 firstdb
    psql (12.2)
    Type "help" for help.

    firstdb=#

to kill postgresql:

    $ kill -INT `head -1 /home/wendell/usr/local/databases/pgsql_data/postmaster.pid`

CMake

    $ wget https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4.tar.gz
    $ tar zxvf cmake-3.16.4.tar.gz
    $ cd cmake-3.16.4
    $ ./configure --prefix=/home/wendell/usr/local
    $ make
    $ make install

    $ export CMAKE_ROOT=/home/wendell/usr/local/share/cmake-3.16

JSON-C

    $ git clone https://github.com/json-c/json-c.git
    $ cd json-c/
    $ sh autogen.sh
    $ ./configure --prefix=/home/wendell/usr/local

(and went back and re-build postgis)

MobilityDB

   git clone https://github.com/ULB-CoDE-WIT/MobilityDB
   $ ~/usr/local/bin/cmake  ..
   $ make
   $ make install

now try to use it

    $ createdb -p 55432 mobile
    $ psql -p 55432 mobile
psql (11.7)
Type "help" for help.

    mobile=# CREATE EXTENSION MobilityDB CASCADE;
NOTICE:  installing required extension "postgis"
CREATE EXTENSION
    mobile=#

YIPEE!!!

now for Python:

install packages

    $ ~/usr/local/bin/pip3.7 install sqlalchemy
    $ ~/usr/local/bin/pip3.7 install shapely
    $ ~/usr/local/bin/pip3.7 install mobilitydb-sqlalchemy

all ok.

FAILED:

    $ ~/usr/local/bin/pip3.7 install movingpandas
      ImportError: /tmp/pip-build-env-smcy4zrs/overlay/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-x86_64-linux-gnu.so: failed to map segment from shared object: Operation not permitted

this helped:

        $ export TMPDIR=/home/wendell/tmp

However,

    $ ~/usr/local/bin/pip3.7 install cartopy
  Proj version 4.8.0 is installed, but cartopy requires at least version 4.9.0.

ok, will try to get my own...

    $ wget https://download.osgeo.org/proj/proj-7.0.0.tar.gz
    $ wget https://download.osgeo.org/proj/proj-data-1.0.tar.gz

    $ tar zxvf proj-7.0.0.tar.gz

    $ ./configure --prefix=/home/wendell/usr/local

checking for SQLITE3... configure: error: Package requirements (sqlite3 >= 3.11) were not met:
Requested 'sqlite3 >= 3.11' but version of SQLite is 3.7.17

SQLite3

    $ unzip sqlite-src-3310100.zip
    $ ./configure --prefix=/home/wendell/usr/local

    $ make TCLLIBDIR=/home/wendell/usr/share/tcl8.5/sqlite3 install

Proj-7.0 (NOPE, for several reasons)

    $ export SQLITE3_LIBS=/home/wendell/usr/local/lib
    $ ./configure --prefix=/home/wendell/usr/local

    $ cd/home/wendell/usr/local/share
    $ mkdir proj

    $  export PROJ_LIB=/home/wendell/usr/local/share/proj

and put this (something) into data dir???

    $ wget https://download.osgeo.org/proj/proj-datumgrid-north-america-1.4.zip

    $ tar zxvf ../../proj-data-1.0.tar.gz
and possibly:

    $ unzip ../../proj-datumgrid-north-america-1.4.zip

HELP: (fixed, see below)

error: cannot bind ‘std::unique_ptr<osgeo::proj::GTiffVGridShiftSet>’ lvalue to ‘std::unique_ptr<osgeo::proj::GTiffVGridShiftSet>&&’

libtool: compile:  g++ -std=c++11 -DHAVE_CONFIG_H -I. -DPROJ_LIB=\"/home/wendell/usr/local/share/proj\" -DMUTEX_pthread -I../include -DTIFF_ENABLED -DCURL_ENABLED -Wall -Wextra -Winit-self -Wunused-parameter -Wformat -Werror=format-security -Wno-format-nonliteral -Wlogical-op -Wshadow -Werror=vla -Wmissing-declarations -Wnon-virtual-dtor -Woverloaded-virtual -Wdeprecated -Wzero-as-null-pointer-constant -g -O2 -fvisibility=hidden -MT grids.lo -MD -MP -MF .deps/grids.Tpo -c grids.cpp  -fPIC -DPIC -o .libs/grids.o
grids.cpp: In constructor ‘osgeo::proj::Grid::Grid(const string&, int, int, const osgeo::proj::ExtentAndRes&)’:
grids.cpp:100:40: warning: declaration of ‘name’ shadows a member of 'this' [-Wshadow]
            const ExtentAndRes &extentIn)
                                        ^
grids.cpp: In constructor ‘osgeo::proj::GTiffGrid::GTiffGrid(PJ_CONTEXT*, TIFF*, osgeo::proj::BlockCache&, osgeo::proj::File*, uint32, const string&, int, int, const osgeo::proj::ExtentAndRes&, osgeo::proj::TIFFDataType, uint16, uint16, bool)’:
grids.cpp:479:25: warning: declaration of ‘name’ shadows a member of 'this' [-Wshadow]
             std::string name;
                         ^
grids.cpp: In static member function ‘static std::unique_ptr<osgeo::proj::VerticalShiftGridSet> osgeo::proj::VerticalShiftGridSet::open(PJ_CONTEXT*, const string&)’:
grids.cpp:1379:16: error: cannot bind ‘std::unique_ptr<osgeo::proj::GTiffVGridShiftSet>’ lvalue to ‘std::unique_ptr<osgeo::proj::GTiffVGridShiftSet>&&’
         return set;
                ^
In file included from /usr/include/c++/4.8.2/memory:81:0,
                 from grids.hpp:31,
                 from grids.cpp:34:
/usr/include/c++/4.8.2/bits/unique_ptr.h:169:2: error:   initializing argument 1 of ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Up, _Ep>&&) [with _Up = osgeo::proj::GTiffVGridShiftSet; _Ep = std::default_delete<osgeo::proj::GTiffVGridShiftSet>; <template-parameter-2-3> = void; _Tp = osgeo::proj::VerticalShiftGridSet; _Dp = std::default_delete<osgeo::proj::VerticalShiftGridSet>]’
  unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
  ^
grids.cpp: In static member function ‘static std::unique_ptr<osgeo::proj::HorizontalShiftGridSet> osgeo::proj::HorizontalShiftGridSet::open(PJ_CONTEXT*, const string&)’:
grids.cpp:2357:16: error: cannot bind ‘std::unique_ptr<osgeo::proj::GTiffHGridShiftSet>’ lvalue to ‘std::unique_ptr<osgeo::proj::GTiffHGridShiftSet>&&’
         return set;
                ^
In file included from /usr/include/c++/4.8.2/memory:81:0,
                 from grids.hpp:31,
                 from grids.cpp:34:
/usr/include/c++/4.8.2/bits/unique_ptr.h:169:2: error:   initializing argument 1 of ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Up, _Ep>&&) [with _Up = osgeo::proj::GTiffHGridShiftSet; _Ep = std::default_delete<osgeo::proj::GTiffHGridShiftSet>; <template-parameter-2-3> = void; _Tp = osgeo::proj::HorizontalShiftGridSet; _Dp = std::default_delete<osgeo::proj::HorizontalShiftGridSet>]’
  unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
  ^
grids.cpp: In static member function ‘static std::unique_ptr<osgeo::proj::GenericShiftGridSet> osgeo::proj::GenericShiftGridSet::open(PJ_CONTEXT*, const string&)’:
grids.cpp:2693:16: error: cannot bind ‘std::unique_ptr<osgeo::proj::GTiffGenericGridShiftSet>’ lvalue to ‘std::unique_ptr<osgeo::proj::GTiffGenericGridShiftSet>&&’
         return set;
                ^
In file included from /usr/include/c++/4.8.2/memory:81:0,
                 from grids.hpp:31,
                 from grids.cpp:34:
/usr/include/c++/4.8.2/bits/unique_ptr.h:169:2: error:   initializing argument 1 of ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Up, _Ep>&&) [with _Up = osgeo::proj::GTiffGenericGridShiftSet; _Ep = std::default_delete<osgeo::proj::GTiffGenericGridShiftSet>; <template-parameter-2-3> = void; _Tp = osgeo::proj::GenericShiftGridSet; _Dp = std::default_delete<osgeo::proj::GenericShiftGridSet>]’
  unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
  ^
make[2]: *** [grids.lo] Error 1
make[2]: Leaving directory `/home/wendell/pkgs/proj-7.0.0/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/wendell/pkgs/proj-7.0.0/src'
make: *** [all-recursive] Error 1

PROJ-6.3.1 (NOPE, too 'new')

and possibly:
    $ unzip ../../proj-datumgrid-north-america-1.4.zip

    $ ./configure --prefix=/home/wendell/usr/local

    $ make
    ./.libs/libproj.so: undefined reference to `sqlite3_column_text'
    ./.libs/libproj.so: undefined reference to `sqlite3_close'
    ./.libs/libproj.so: undefined reference to `sqlite3_reset'
    ./.libs/libproj.so: undefined reference to `sqlite3_result_double'

    $ export SQLITE3_LIBS="-L/home/wendell/usr/local/lib -lsqlite3"
    $ export PKG_CONFIG=/home/wendell/usr/local/home/wendell/usr/local/lib/pkgconfig/sqlite3.pc

    $ ./configure --prefix=/home/wendell/usr/local

NOPE.

PROBLEM

demo requirements

from https://github.com/adonmo/mobilitydb-sqlalchemy-demo/blob/master/backend/requirements.txt but using cherrypy instead of flask:

    $ ~/usr/local/bin/python3.7
    Python 3.7.3 (default, Mar  3 2020, 21:42:22)
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import cherrypy
    >>> import cp_sqlalchemy
    >>> import cherrypy_cors
    >>> import psycopg2
    >>> import mobilitydb_sqlalchemy
    >>> import trajectory
    >>>

SO, it seems like there is a possibility it will work.

and now for the actual demo...

d/l

    $ git clone https://github.com/adonmo/mobilitydb-sqlalchemy-demo.git

populate

edited populate_data.py and models.py to remove all Flask references and replace with sqlalchemy (and mobilitydb_sqlalchemy), without using cp_sqlalchemy nor flask_sqlalchemy

    $ ~/usr/local/bin/python3.7 populate_data.py
    Trying to populate 163 rows
    inserted: 1
    inserted: 2
    ...
    inserted: 61
    inserted: 63
    Couldn't save trip #65 of length 3
    Couldn't save trip #67 of length 11
    ...
    Couldn't save trip #38090 of length 2
    Couldn't save trip #38092 of length 5

I think a lot of trips had duplicate timestamps, which MobilityDB doesn't like.

and then to verify:

    $ psql -p 55432 mobile
    psql (11.7)
    Type "help" for help.

    mobile=# select trip_id, replace(asText(trip),',',E'\n') as ttt from trips;

 trip_id |                                 ttt
---------+---------------------------------------------------------------------
       1 | [POINT(-10.9393413858164 -37.0627421097422)@2014-09-13 07:24:32+00 +
         |  POINT(-10.939341385769 -37.0627421097809)@2014-09-13 07:24:37+00  +
         |  POINT(-10.9393239478718 -37.0627645137212)@2014-09-13 07:24:42+00 +
         |  POINT(-10.9392105616561 -37.0628430455445)@2014-09-13 07:24:47+00 +
         |  POINT(-10.9389389789911 -37.0628785984113)@2014-09-13 07:24:53+00 +
         |  POINT(-10.9385435911514 -37.0628386631358)@2014-09-13 07:24:59+00 +
         |  POINT(-10.9383460576505 -37.0625875627021)@2014-09-13 07:25:04+00 +
         |  POINT(-10.9384484455051 -37.0619998251528)@2014-09-13 07:25:10+00 +
         |  POINT(-10.9386660746204 -37.0614989339645)@2014-09-13 07:25:15+00 +
         |  POINT(-10.9389862284613 -37.0608192197261)@2014-09-13 07:25:21+00 +

populate; Mar 24

Tiles:

Trajectoies:

instr are below

CherryPy server

references:

1) edit site.py to make devel.ilc reference the new Mdb stuff

2) copy over files:

    $ mkdir mdb_frontend
    $ mkdir mdb_backend
    $ cd mdb_frontend/

    $ mv ../mdb.html .
    $ cp -r ~/mobilitydb/mobilitydb-sqlalchemy-demo/frontend/public .
    $ cp -r ~/mobilitydb/mobilitydb-sqlalchemy-demo/frontend/src .

NOPE. Gave up on the copy stuff, will do npm...

will attempt to use npm...

1) copy over files to new dir

    $ cp -R frontend npm_frontend
    $ cd npm_frontend/

start the install

    $ npm init

package name: (frontend) mdb
version: (0.1.0)
entry point: (index.js)
git repository:
keywords: mobilitydb
author: wendell
license: (ISC)
About to write to /home/wendell/mobilitydb/mobilitydb-sqlalchemy-demo/npm_frontend/package.json:

seemed ok, but need to cleanup & install (once) the first time

    $ rm yarn.lock
    $ npm install

<did lots of stuff>

added 1701 packages from 1759 contributors and audited 921257 packages in 69.444s
found 0 vulnerabilities

ok, now for the actual build:

    $ npm run-script build

> mdb@0.1.0 build /home/wendell/mobilitydb/mobilitydb-sqlalchemy-demo/npm_frontend
> react-scripts build

Creating an optimized production build...
Compiled with warnings.

./src/hooks/trips.js
  Line 25:6:  React Hook useEffect has a missing dependency: 'defaultState'. Either include it or remove the dependency array  react-hooks/exhaustive-deps
  Line 54:6:  React Hook useEffect has a missing dependency: 'defaultState'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

./src/App.js
  Line 46:6:   React Hook useEffect has a missing dependency: 'setTimeSlider'. Either include it or remove the dependency array              react-hooks/exhaustive-deps
  Line 70:35:  Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener  react/jsx-no-target-blank

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

File sizes after gzip:

  419.14 KB  build/static/js/2.2e4fa74e.chunk.js
  60.47 KB   build/static/css/2.90a264fd.chunk.css
  3.34 KB    build/static/js/main.4dbfebc0.chunk.js
  769 B      build/static/js/runtime-main.f9e7e40f.js
  425 B      build/static/css/main.7c35d752.chunk.css

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  npm install -g serve
  serve -s build

Find out more about deployment here:

  bit.ly/CRA-deploy

now copy over files

    $ cd /home/wendell/webapps/cherry/mdb
    $ cp -R ~/mobilitydb/mobilitydb-sqlalchemy-demo/npm_frontend/build/* .

Hmm..., but manifest.json and static dir at top level:

    $ cp mdb/manifest.json .
    $ cp -R mdb/static .

YIPEE!!! a map shows up!!!

AND it is working (BUT making calls to adonmo, not to ilc!)

the query

https://api.adonmo.com/mobilitydb_sqlalchemy_demo/get_trips_by_spatial_query?lat=-10.917437164838226&lng=-37.06907272338868

it seems that it is in the .env file:

was:
    REACT_APP_BASE_URL=https://api.adonmo.com
now:
    REACT_APP_BASE_URL=https://devel.ilikecarrots.com

reproduceable build:

    $ npm run-script build

    $ cp build/manifest.json /home/wendell/webapps/cherry
    $ cp build/logo192.png  /home/wendell/webapps/cherry
    $ cp -R build/static /home/wendell/webapps/cherry
    $ cp build/* /home/wendell/webapps/cherry/mdb
    cp: omitting directory ‘build/static’

and edit for url:

    vim src/api.js

  //wt: const path = `${BASE_URL}/mobilitydb_sqlalchemy_demo/get_all_trips`;
  const path = `${BASE_URL}/get_all_trips`;

  //wt: const path = `${BASE_URL}/mobilitydb_sqlalchemy_demo/get_trips_by_spatial_query?` + queryParams;
  const path = `${BASE_URL}/get_trips_by_spatial_query?` + queryParams;

ok, now for the backend and d.b. access

change dirs to be mdb_frontend and mdb_backend

and copy over backend files (now these are in ./copy.py):

    $ mv mdb mdb_frontend
    $ mkdir mdb_backend
    $ cd mdb_backend/
    $ cp ~/mobilitydb/mobilitydb-sqlalchemy-demo/backend/main.py  mdb_main.py
    $ cp ~/mobilitydb/mobilitydb-sqlalchemy-demo/backend/models.py .

after various edits...

Ok, seem to have server (site.py) correctly calling routines in mdb_main.py

now to actually connect to database

ok, it's not very Pythonic, BUT IT WORKS!!!

transfer d.b. from rserver

1) dump to text and gzip

    pg_dump -t 'tz*' ciwsdb > ciwsdb_tz_tables.sql
    gzip ciwsdb_tz_tables.sql
    pg_dump -t 'meta*' ciwsdb > ciwsdb_meta_tables.sql
    pg_dump -t 'ciws*' ciwsdb > ciwsdb_ciws_tables.sql
    gzip ciwsdb_ciws_tables.sql

2) tx to webfaction

    $ scp ciwsdb_tz_tables.sql.gz wendell@ilikecarrots.com:mobilitydb
    $ scp ciwsdb_meta_tables.sql wendell@ilikecarrots.com:mobilitydb
    $ scp ciwsdb_ciws_tables.sql.gz wendell@ilikecarrots.com:mobilitydb

3) create d.b. on webfaction

    $ createdb -p 55432 ciwsdb

    $ psql -p 55432 ciwsdb
    psql (11.7)
    Type "help" for help.

    ciwsdb=# CREATE EXTENSION MobilityDB CASCADE;
    NOTICE:  installing required extension "postgis"
    CREATE EXTENSION
    ciwsdb=# \q

4) populate tables (lots of user 'wturner' does not exist errors)

    $ psql -p 55432 -d ciwsdb -f ciwsdb_meta_tables.sql

    $ gzip -d ciwsdb_tz_tables.sql.gz
    $ psql -p 55432 -d ciwsdb -f ciwsdb_tz_tables.sql

    $ gzip -d ciwsdb_ciws_tables.sql.gz
    $ psql -p 55432 -d ciwsdb -f ciwsdb_ciws_tables.sql

new directory layout

Everything is under webapps/cherry/mdb_demo (unfortunately)

d.b. test query

# select fid, acid, replace(asText(traj),',',E'\n') as traj_x from tz_2019_08_22 limit 1;

      fid       |  acid  |                       traj_x
----------------+--------+----------------------------------------------------
 20190822000190 | SWA183 | [POINT(-77.7 43.1)@2019-08-22 21:52:00+00         +
                |        |  POINT(-77.71667 43.06667)@2019-08-22 21:53:00+00 +
                |        |  POINT(-77.76667 43)@2019-08-22 21:54:00+00       +
                |        |  POINT(-77.78333 42.91667)@2019-08-22 21:55:00+00 +
...
                |        |  POINT(-76.6 39.1)@2019-08-22 22:39:00+00         +
                |        |  POINT(-76.63333 39.13333)@2019-08-22 22:40:00+00 +
                |        |  POINT(-76.66667 39.16667)@2019-08-22 22:41:00+00]
(1 row)

PROBLEM

mdb demo points and data are all (lat, lon) all TZ data is (lon, lat)

duh!

    $ ~/usr/local/bin/pip3.7 install python-mobilitydb

Successfully installed Spans-1.1.0 asyncpg-0.20.1 attrs-19.3.0 importlib-metadata-1.5.0 packaging-20.3 parsec-3.5 pluggy-0.13.1 postgis-1.0.4 psycopg2-binary-2.8.4 py-1.8.1 pyparsing-2.4.6 pytest-5.3.5 pytest-asyncio-0.10.0 python-mobilitydb-0.1.1 wcwidth-0.1.8 zipp-3.1.0
You are using pip version 19.0.3, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

upgrade to use TGeogPoint

    $ ~/usr/local/bin/pip3.7 uninstall mobilitydb-sqlalchemy

Uninstalling mobilitydb-sqlalchemy-0.2.0:
  Would remove:
    /home/wendell/usr/local/lib/python3.7/site-packages/mobilitydb_sqlalchemy-0.2.0.dist-info/*
    /home/wendell/usr/local/lib/python3.7/site-packages/mobilitydb_sqlalchemy/*

Proceed (y/n)? y

  Successfully uninstalled mobilitydb-sqlalchemy-0.2.0

    $ ~/usr/local/bin/pip3.7 install mobilitydb-sqlalchemy

Collecting mobilitydb-sqlalchemy
  Downloading https://files.pythonhosted.org/packages/83/c2/2bf13e6ff13ec46c7cc14d3f515de9e0ef243209a6a8484c7f21c4f7db11/mobilitydb_sqlalchemy-0.2.1-py3-none-any.whl
Requirement already satisfied: pandas<0.26.0,>=0.25.3 in /home/wendell/usr/local/lib/python3.7/site-packages (from mobilitydb-sqlalchemy) (0.25.3)
Requirement already satisfied: geoalchemy2<0.7.0,>=0.6.3 in /home/wendell/usr/local/lib/python3.7/site-packages (from mobilitydb-sqlalchemy) (0.6.3)
Requirement already satisfied: sqlalchemy<2.0.0,>=1.3.11 in /home/wendell/usr/local/lib/python3.7/site-packages (from mobilitydb-sqlalchemy) (1.3.13)
Requirement already satisfied: shapely<2.0.0,>=1.6.4 in /home/wendell/usr/local/lib/python3.7/site-packages (from mobilitydb-sqlalchemy) (1.7.0)
Requirement already satisfied: pytz>=2017.2 in /home/wendell/usr/local/lib/python3.7/site-packages (from pandas<0.26.0,>=0.25.3->mobilitydb-sqlalchemy) (2019.1)
Requirement already satisfied: numpy>=1.13.3 in /home/wendell/usr/local/lib/python3.7/site-packages (from pandas<0.26.0,>=0.25.3->mobilitydb-sqlalchemy) (1.18.1)
Requirement already satisfied: python-dateutil>=2.6.1 in /home/wendell/usr/local/lib/python3.7/site-packages (from pandas<0.26.0,>=0.25.3->mobilitydb-sqlalchemy) (2.8.1)
Requirement already satisfied: six>=1.5 in /home/wendell/usr/local/lib/python3.7/site-packages (from python-dateutil>=2.6.1->pandas<0.26.0,>=0.25.3->mobilitydb-sqlalchemy) (1.14.0)
Installing collected packages: mobilitydb-sqlalchemy
Successfully installed mobilitydb-sqlalchemy-0.2.1
You are using pip version 19.0.3, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

webfaction account upgraded...

1) desparate attempts to install sqlite3 without messing up mobilitydb

 2020-03-06 17:30:39 cd sqlite-src-3310100
 2020-03-06 17:31:22 ./configure --prefix=/home/wendell/usr/local_sqlite
 2020-03-06 17:31:32 make
 2020-03-06 17:33:21 make TCLLIBDIR=/home/wendell/usr/share_sqlite/usr/share/tcl8.5/sqlite3 install

2) proj-6 (NOPE.)

    $ export SQLITE3_CFLAGS=-I/home/wendell/usr/local_sqlite/include
    $ export SQLITE3_LIBS="-L/home/wendell/usr/local_sqlite/lib -lsqlite3"
    $ ./configure --prefix=/home/wendell/usr/local
    $ make
    $ make install

seemed to go ok, but I don't think I put any data (of datums) in the data/ dir (???)

3) back to movingpandas

    $ ~/usr/local/bin/pip3.7 install movingpandas

NOPE. The problem is:

17:54:31 mobilitydb $ ~/usr/local/bin/pip3.7 install cartopy

HOWEVER,

$ ~/usr/local/bin/python3.7

Python 3.7.3 (default, Mar 3 2020, 21:42:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux Type "help", "copyright", "credits" or "license" for more information.

import numpy numpy.version.version '1.18.1'

Hmm..., maybe cartopy is barfing on Cython ???

The list of cartopy dependencies is here: https://scitools.org.uk/cartopy/docs/v0.15/installing.html

    $ ~/usr/local/bin/pip3.7 install Cython --install-option="--no-cython-compile"

/home/wendell/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py:207: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
  cmdoptions.check_install_build_global(options)
Collecting Cython
  Downloading https://files.pythonhosted.org/packages/d9/82/d01e767abb9c4a5c07a6a1e6f4d5a8dfce7369318d31f48a52374094372e/Cython-0.29.15.tar.gz (2.1MB)
    100% |████████████████████████████████| 2.1MB 9.2MB/s
Skipping bdist_wheel for Cython, due to binaries being disabled for it.
Installing collected packages: Cython
  Running setup.py install for Cython ... done
Successfully installed Cython-0.29.15

will try this:

18:06:11 mobilitydb $ export TMPDIR=/home/wendell/tmp
18:06:14 mobilitydb $ ~/usr/local/bin/pip3.7 install cartopy

NOPE

18:24:53 ~ $ ~/usr/local/bin/pip3.7 install geopandas

FROM Anita's blog:

Note that it is NOT recommended to install MovingPandas from PyPI! If you're on Windows or Mac, many GeoPandas / MovingPandas dependencies cannot be pip installed (for details see the corresponding notes in the GeoPandas documentation). On Ubuntu, pip install fails on cartopy with "Proj 4.9.0 must be installed".

from: https://stackoverflow.com/questions/53697814/using-pip-install-to-install-cartopy-but-missing-proj-version-at-least-4-9-0 says these are needed:

    !apt-get install libproj-dev proj-data proj-bin
    !apt-get install libgeos-dev
    !pip install cython
    !pip install cartopy

how about this:

    $ ~/usr/local/bin/pip3.7 setup.py  build_ext --inplace -I/home/wendell/usr/local/include -L/home/wendell/usr/local/lib

THIS CAME CLOSE!!!

    $ export PKG_CONFIG_PATH=/home/wendell/usr/local/lib/pkgconfig/
    $ ~/usr/local/bin/python3.7 setup.py  build_ext --inplace -I/home/wendell/usr/local/include -L/home/wendell/usr/local/lib

#error 'To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'

this said: https://github.com/opengribs/XyGrib/issues/181 that older vesions work..

WILL TRY proj-5.2.0

    wget https://download.osgeo.org/proj/proj-5.2.0.tar.gz
    tar zxvf proj-5.2.0.tar.gz
    cd proj-5.2.0
    export SQLITE3_CFLAGS=-I/home/wendell/usr/local_sqlite/include
    export SQLITE3_LIBS="-L/home/wendell/usr/local_sqlite/lib -lsqlite3"
    ./configure --prefix=/home/wendell/usr/local
    make
    make install

ok, continuing...

    $ cd ../Cartopy-0.17.0
    $ ~/usr/local/bin/python3.7 setup.py  build_ext --inplace -I/home/wendell/usr/local/include -L/home/wendell/usr/local/lib

    $ ~/usr/local/bin/python3.7 setup.py  install

Adding numpy 1.18.1 to easy-install.pth file
Installing f2py script to /home/wendell/usr/local/bin
Installing f2py3 script to /home/wendell/usr/local/bin
Installing f2py3.7 script to /home/wendell/usr/local/bin

Using /home/wendell/usr/local/lib/python3.7/site-packages
Finished processing dependencies for Cartopy==0.17.0

so, I guess it installed...

    $ ~/usr/local/bin/pip3.7 install movingpandas

Successfully built movingpandas bokeh PyYAML tornado
Installing collected packages: kiwisolver, cycler, matplotlib, param, pyviz-comms, holoviews, pyct, colorcet, PyYAML, MarkupSafe, Jinja2, pillow, tornado, bokeh, hvplot, geoviews, movingpandas
Successfully installed Jinja2-2.11.1 MarkupSafe-1.1.1 PyYAML-5.3 bokeh-1.4.0 colorcet-2.0.2 cycler-0.10.0 geoviews-1.6.6 holoviews-1.12.7 hvplot-0.5.2 kiwisolver-1.1.0 matplotlib-3.2.0 movingpandas-0.2rc1 param-1.9.3 pillow-7.0.0 pyct-0.4.6 pyviz-comms-0.7.3 tornado-6.0.4
You are using pip version 19.0.3, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

and for the finale:

    $ ~/usr/local/bin/python3.7

Python 3.7.3 (default, Mar  3 2020, 21:42:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import movingpandas
>>>

YIPEE!!!!!!!!!!!!!!

now to add polygons

    gzip -d pathenr_poly_table.sql.gz
    psql -p 55432 -d ciwsdb -f pathenr_poly_table.sql

and to query:

    $ psql -p 55432 ciwsdb

psql (11.7)
Type "help" for help.

ciwsdb=# \dt pathenr_poly
            List of relations
 Schema |     Name     | Type  |  Owner
--------+--------------+-------+---------
 public | pathenr_poly | table | wendell
(1 row)


ciwsdb=# \d pathenr_poly
                    Table "public.pathenr_poly"
 Column  |          Type          | Collation | Nullable | Default
---------+------------------------+-----------+----------+---------
 airport | text                   |           |          |
 name    | text                   |           |          |
 flow    | text                   |           |          |
 artcc   | text                   |           |          |
 poly    | geometry(Polygon,4326) |           |          |


ciwsdb=# select airport, name, flow, artcc, substr(ST_asText(poly),1,40) as xpoly from pathenr_poly  limit 4;
 airport | name  | flow | artcc |                  xpoly
---------+-------+------+-------+------------------------------------------
 ORD     | ORD14 | ARR  | ZAU   | POLYGON((-89.276 42.347,-88.699 42.337,-
 ORD     | ORD15 | ARR  | ZAU   | POLYGON((-90.781 43.664,-89.13 42.564,-8
 ORD     | ORD16 | ARR  | ZAU   | POLYGON((-90.274 42.557,-90.274 42.289,-
 ORD     | ORD17 | ARR  | ZAU   | POLYGON((-93.07 42.629,-93.399 41.824,-9
(4 rows)

However, there's still the "byte-order" problemS

SOLUTION: wrote (lame) routine to SWAP all lat,lon for lon, lat AND IT WORKS!

memory usage

from Nick's ticket email and ??? web page:

    node --max-old-space-size=460 `which npm` install

npm WARN @ant-design/icons-react@2.0.1 requires a peer of @ant-design/icons@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-react-app@5.2.0 requires a peer of eslint-plugin-flowtype@3.x but none is installed. You must install peer dependencies yourself.
npm WARN react-scripts@3.4.0 requires a peer of typescript@^3.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@8.0.2 requires a peer of node-sass@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@8.0.2 requires a peer of sass@^1.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@8.0.2 requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/watchpack/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/jest-haste-map/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

audited 921257 packages in 23.169s
found 17 moderate severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details

will see if that changes anything...

us this:

Polygons

    https://devel.ilikecarrots.com/get_a_poly_query

Note: that serializer function only works on trajectory/points, and lat/lng and timestamp seem to be off by `.

Note: just used JSON text string of WKT of polycon for transmission

Note: Polygon points are still lat,lon; these SHOULD BE lon lat!

$ ~/usr/local/bin/pip3.7 install geojson

coordsToLatLng

https://stackoverflow.com/questions/47609638/show-geojson-featurecollection-with-leaflet

var geojson = L.geoJSON(states, {
    coordsToLatLng: function (p) {
        p = proj4(fromProjection,toProjection,p);  // reproject each point
        p = [p[1],p[0]]    // swap the values
        return p;          // return the lat/lng pair
    }
}).addTo(map);

HOWEVER, it works on cherry.ilc !!!???

and https://stackoverflow.com/questions/45166926/cannot-stringify-geojson-data

NOPE. THAT WASN'T IT

BUT, I don't know why I had to reverse just the track points; the polygons (below, as GeoJSON) did NOT have to be reversed. ???

Solution:

the answer was in this: https://react-leaflet.js.org/docs/en/components#geojson

GeoJSON: Properties: data: GeoJSON (required). This property will not be updated if it is changed after the component is mounted.

So, the solution was a function to return the which gets evaluated on each redraw/refresh.

YIPEE!!!

date picker

this one looks nice: https://www.npmjs.com/package/react-date-picker

    npm install react-date-picker

but lots of WARN about missing packages (You must install peer dependencies yourself.)

what about Ant-Design?

Notes on that page:

    import moment from 'moment';

    // It's recommended to set locale in entry file globaly.
    import 'moment/locale/zh-cn';
    moment.locale('zh-cn');

    <DatePicker defaultValue={moment('2015-01-01', 'YYYY-MM-DD')} />

ok will try:

02:58:46 npm_build $ npm install moment/locale/utc

done.