Links

   Quran Explorer - Interactive Audio Recitations & Translations

Wednesday, April 30, 2014

Gaffes


Since this blog is about my own experience while coding away my sanity, i think it would be fir enought to share my blunders too... not just wat works!!!!!!!!

In no particular order....

1. Strange PostgreSQL Error message
    "ERROR:  input of anonymous composite types is not implemented "

     This is an error message i had never encountered before but , against my own advice, instead of backtracking and looking for documentation of the error or googling, i went straight ahead to my new ui code and tried to debug.... i wasted almost 8 man hours... a whole official day in other words.

Later on i discovered that i had forgoten to specify a datataype for a db column in the sql script !!!!!!!!


2. New Django Models 'Refusing' to appear on the Admin site
   Was in 'debug' mode for about 2 days

   Found out that i had forgoten to register the new Models at admin.py




Friday, April 11, 2014

Asset Tracking via GPS

Implemented using a combination of Traccar and OpenGTS (and Google Earth)


On OpenGTS side i only needed
track.war (Web interface)
events.war (data retrieval by robots, GoogleEarth etc)
gprmc.war (http interface for (some)GPS devices)

Traccar was the actual 'engine' running the protocols and accepting connections and eventualy pushing them into the DB.


Process:
1. Build OpenGTS then dump the database
2. Update Traccars traccar.cfg to point to the opengts db
3. Run the service and wait for connections


Contact me for a demo link

PostGIS example tutorial


Fellow geekerati and Random Googlers!!!

The following is the process(with a few slight variations each time) that i always take whenever i have a postGIS related project. 
And.... need i say?... it has never let me down.


1. INITIALIZATION - Create a spatially-enabled database
====================

NOTE: tavevo is the database name. change accordingly

a. confirm postgis version
    #psql -d tavevo -c "SELECT postgis_full_version();"
    POSTGIS="1.5.3" GEOS="3.2.1-CAPI-1.6.1" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.8" USE_STATS

b. #psql -d tavevo < /usr/sesame/systems/sesame/postgis-1.5/postgis.sql
    Load the PostGIS object and function definitions into your database

c. #psql -d tavevo < /usr/sesame/systems/sesame/postgis-1.5/spatial_ref_sys.sql
    For a complete set of EPSG coordinate system definition identifiers,
    you can also load the spatial_ref_sys.sql definitions file and populate the spatial_ref_sys table.
    This will permit you to perform ST_Transform() operations on geometries.


2. CREATE ROLE/USER
#sudo su postgres
CREATE ROLE gisgroup NOSUPERUSER NOINHERIT CREATEDB NOCREATEROLE;
CREATE ROLE admin LOGIN PASSWORD '@dm1n' NOINHERIT;
GRANT gisgroup TO admin;


3. PERMISSIONS
Connect:
#psql -U postgres tavevo

Give permissions:
ALTER TABLE geometry_columns OWNER TO admin;
ALTER TABLE spatial_ref_sys OWNER TO admin;
ALTER TABLE water_meter OWNER TO admin;

--TESTING
--GRANT ALL ON TABLE geometry_columns TO admin;
--GRANT ALL ON TABLE spatial_ref_sys TO admin;
--GRANT ALL ON TABLE water_meter TO admin;



4. Create SCHEMA
CREATE SCHEMA gis_schema AUTHORIZATION admin;


5. GIVE OWNERSHIP TO admin
ALTER DATABASE tavevo OWNER TO "admin";


6. UPLOAD DATA

    a. COAST ADMINISTRATIVE

        Generate SQL:
                #shp2pgsql -I -s 32633 KEN-1.shp coast_admin > coast_admin.sql
                Shapefile type: Polygon
                Postgis type: MULTIPOLYGON[2]

        Execute SQL:
                #psql -U admin -d tavevo < coast_admin.sql

    b. COAST BOUNDARIES

        Generate SQL:
            #shp2pgsql -I -s 32633 KEN-1_boundaries.shp coast_boundaries > /usr/sesame/systems/tavevo/database/coast_boundaries.sql
            Shapefile type: Arc
            Postgis type: MULTILINESTRING[2]

        Execute SQL:
            #psql -U admin -d tavevo < coast_boundaries.sql

    c. KENYA - ADMINISTRATIVE
        Generate SQL:
            #shp2pgsql -I -s 32633 KEN.shp kenya_admin > /usr/sesame/systems/tavevo/database/kenya_admin.sql
            Shapefile type: Polygon
            Postgis type: MULTIPOLYGON[2]
        Execute SQL:
            #psql -U admin -d tavevo < kenya_admin.sql