Monday, September 18, 2017

Descriptions of the Gradle build structure

Be The First To Comment
Descriptions of the build gradle file’s parts

Build Java code

apply plugin: ‘java’
apply plugin: ‘war’

This task compiles, tests, and assembles the code into a JAR or WAR file, 
when you run - gradle build

Specify project folder structure

sourceSets{
                main.java.srcDir “src/main”
                test.java.srcDir “src/test”
}

Build with Gradle Wrapper

task wrapper(type: Wrapper) {
    gradleVersion = '2.7'
}

The Gradle Wrapper is the preferred way of starting a Gradle build. It consists of a batch 
script for Windows and a shell script for OS X and Linux. These scripts allow you to run 
a Gradle build without requiring that Gradle be installed on your system.

Friday, September 15, 2017

Tutorial: Sharing Data Between Angular Components - Parent to Child, Child to Parent, and between siblings

Be The First To Comment
Great video talking about sharing Data Between Angular Components - Parent to Child, Child to Parent, and between siblings by Jeff Delaney, AngularFirebase. 



Wednesday, September 13, 2017

Wiring Leaflet, ESRI-leaflet, and Angular for a web map

Be The First To Comment
Basic prototype wiring to map geospatial information using Leaflet, ESRI-leaflet, Angular 4.  There are several nice examples out there, but it is a quick and dirty way of putting all things together and display the map using Angular/Cli.

Step 1. Generate an angular project from angular/cli
                ng new leafletPrototype

Step2. Install all dependencies
a.     Npm install leaflet --save
b.     Nmp install esri-leaflet --save
c.      Npm install @types/leaflet –save

Your pacakage.json will looks like –
"dependencies": {
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "@types/leaflet": "^1.0.69",
    "core-js": "^2.4.1",
    "esri-leaflet": "^2.1.1",
    "leaflet": "^1.2.0",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },


Step 3. Configure .angular-cli.json
Add leaflet and esri-leaflet styles and scripts in .angular-cli.json
"styles": [
        "styles.scss",
        "../node_modules/leaflet/dist/leaflet.css",
        "../node_modules/leaflet-draw/dist/leaflet.draw.css"
      ],


      "scripts": ["../node_modules/leaflet/dist/leaflet.js",
        "../node_modules/esri-leaflet/dist/esri-leaflet.js"
      ],

Step 4. Now, run “ng serve” and see if any errors while importing leaflet libraries.

Compute zonal statistics on area of interest polygon on fly

Be The First To Comment
Draft to compute zonal statistics on area of interest polygon or shape draw on leaflet using PostgreSql and Java -

Geometry extracted from leaflet as GeoJson.

Polygon-
{"type":"Feature","properties":{"desc":null,"image":null},"geometry":{"type":"Polygon","coordinates":[[[-117.103271484375,34.264026473152875],[-117.1142578125,34.14818102254435],[-117.03186035156251,34.10498222546687],[-116.91925048828124,34.14363482031264],[-116.94946289062499,34.25494631082515],[-117.0867919921875,34.252676117101515],[-117.103271484375,34.264026473152875]]]}}


{"type":"Feature","properties":{"desc":null,"image":null},"geometry":{"type":"Polygon","coordinates":[[[-116.86981201171875,34.11407854333859],[-116.86981201171875,34.24132422972854],[-116.71874999999999,34.24132422972854],[-116.71874999999999,34.11407854333859],[-116.86981201171875,34.11407854333859]]]}}

Point-
{"type":"Feature","properties":{"desc":null,"image":null},"geometry":{"type":"Point","coordinates":[-116.9879150390625,34.048108084909835]}}


Area of GeoJson
Select (ST_Area(ST_GeomFromText
('POLYGON ((-117.16918945312501 34.27083595165,-117.1307373046875 34.166363384737892,-117.00988769531251 34.161818161230386,-116.93298339843751 34.239053668516412,-116.98516845703126 34.27083595165,-117.16918945312501 34.27083595165))',4326)))



Zonal statistics for each raster tile -

SELECT rid, (ST_SummaryStats (ST_Clip(rast,ST_GeomFromText('POLYGON ((-117.16918945312501 34.27083595165,-117.1307373046875 34.166363384737892,-117.00988769531251 34.161818161230386,-116.93298339843751 34.239053668516412,-116.98516845703126 34.27083595165,-117.16918945312501 34.27083595165))',4326),true))).*
FROM public.biodiv_ssolnw_wgs84
WHERE ST_Intersects
(rast,ST_GeomFromText
('POLYGON ((-117.16918945312501 34.27083595165,-117.1307373046875 34.166363384737892,-117.00988769531251 34.161818161230386,-116.93298339843751 34.239053668516412,-116.98516845703126 34.27083595165,-117.16918945312501 34.27083595165))',4326))
Group By rid

Monday, August 28, 2017

Quick cheat-sheet on Angular/cli

Be The First To Comment
Quick cheat-sheet on Angular/cli to generate boiler plate codes.

Install Angular/cli
npm install –g @angular/cli

Check Agnular/cli version
ng –v
        or
npm list –g  @angular/cli --depth=0

Generate  files without installing it
ng new ng2CliApp --skip-install

Create new project with out writing the files in but report them commandline console
ng new ng2CliApp --dry-run

Create new project with app prefix
ng new ng2CliApp --prefix coolapp --dry-run

Create new project without test files
ng new ng2CliApp  --skip-tests --prefix cool_ng2CliApp --dry-run

Create new project with style-sheets
ng new ng2CliApp --skip-tests --prefix cool_ng2CliApp --style scss 

Create new project with Routing
ng new ng2CliApp --routing --skip-tests --prefix cool_ng2CliApp --style scss --skip-install

Create new Component
ng g component my-new-component

Tuesday, August 22, 2017

Solved: Cannot connect Postgre in VM from host

Be The First To Comment
Used vagrant for setting up the VM, so set private network and port forward in vagrant file as below -
               
                 migration.vm.network "private_network", ip: "192.168.33.10"
                 migration.vm.network "forwarded_port",guest:5432 , host:15432 


1. Use telnet localhost 15432 to see if the port is open (Host)


Still can not connect to PostgresSql running in VM  :(

Then

2. Edit postgresql.conf (Guest)
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

           listen_addresses = '*'


3.  Add following in pg_hba.conf

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all              all            0.0.0.0/0               md5


4. Finally, able to connect to Postgres via localhost:15432

Thursday, August 17, 2017

Getting started with Raster and PostGIS - I

Be The First To Comment
Steps for loading a raster in PostGIS (PgSql 9.4/ PostGIS 2.2) and pull it from database to view in QGIS 2.14.17.

1. Generate SQL for raster [NOTE: Do not create PostGIS table name starts with underscore, it creates problem while adding raster to QGIS from PostGIS database using DB Manager]

        raster2pgsql -s 4326 -I -C -M -F -t 50x50 -N nan biodiv_ssolnw.tif > biodiv_ssolnw.sql






2. Import generated raster into PostGIS database [Make sure to enable postgis extension in db]

         psql -h localhost -U postgres -d ecolservicedb -f biodiv_ssolnw.sql

the output is:
Processing 1/1: ags_473038164.tif
BEGIN
CREATE TABLE

INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1


….
CREATE INDEX
ANALYZE
NOTICE:  Adding SRID constraint
CONTEXT:  PL/pgSQL function addrasterconstraints(name,name,name,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean) line 53 at RETURN
NOTICE:  Adding scale-X constraint
CONTEXT:  PL/pgSQL function addrasterconstraints(name,name,name,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean) line 53 at RETURN
NOTICE:  Adding scale-Y constraint
CONTEXT:  PL/pgSQL function addrasterconstraints(name,name,name,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean) line 53 at RETURN
NOTICE:  Adding blocksize-X constraint
CONTEXT:  PL/pgSQL function addrasterconstraints(name,name,name,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean) line 53 at RETURN
NOTICE:  Adding blocksize-Y constraint
CONTEXT:  PL/pgSQL function addrasterconstraints(name,name,name,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean) line 53 at RETURN
NOTICE:  Adding alignment constraint
CONTEXT:  PL/pgSQL function addrasterconstraints(name,name,name,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean) line 53 at RETURN
NOTICE:  Adding number of bands constraint
CONTEXT:  PL/pgSQL function addrasterconstraints(name,name,name,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean) line 53 at RETURN
NOTICE:  Adding pixel type constraint
CONTEXT:  PL/pgSQL function addrasterconstraints(name,name,name,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean) line 53 at RETURN
NOTICE:  Adding nodata value constraint
CONTEXT:  PL/pgSQL function addrasterconstraints(name,name,name,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean) line 53 at RETURN
NOTICE:  Adding out-of-database constraint
CONTEXT:  PL/pgSQL function addrasterconstraints(name,name,name,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean) line 53 at RETURN
NOTICE:  Adding maximum extent constraint
CONTEXT:  PL/pgSQL function addrasterconstraints(name,name,name,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean) line 53 at RETURN
 addrasterconstraints
----------------------

Friday, July 21, 2017

Setup Jenkins Bit-bucket environment in Windows Server 2008

Be The First To Comment
Steps for setting Jenkins/Bitbucket CI environment in Windows - little trickier than Linux

1) Download and Install Jenkins-2.60.1(current as of the day written)

2) Once installed changed the port from C:\Program Files (x86)\Jenkins\jenkins.xml to ‘9090’ and
restart jenkins

3) Set security options to “false” from config.xml

4) Then open localhost:8090 and see if you can see Jenkins Interface

5) Install all default plugins plus following plugins to work Jenkins correctly with Bitbucket and
dev requirements for my workflow
        a. Bitbucket pull request builder plugin
        b. Maven integration plugin
        c. MS build plugin
       d. Next build number plugin
       e. NodeJS plugin
       f. SSH Agent Plugin      
       g. SSh plugin
       h. Self-organizing swarm plugin
       i. Categorized view plugin
       j. Publish-over ssh
       k. Schedule build
       l. Nugget
       m. Vagrant

6) Install git bash in the machine

7) From git bash, generate ssh-keys , ssh-keygen

8) Add the public key(id_rsa.pub) in BitBucket under group account

Wednesday, May 31, 2017

Prevent WPF Global Keyboard Hook from stops working after hitting keys a while C# .NET

Be The First To Comment
The article written by Dylan Currier, Low Level Global Keyboard Hook / Sink in C# .NET is one the simple, easily understandable, and and working post on Global Keyboard hook out there in internet. It worked in my WPF application and I added following line in the WPF app to refresh hook after each key press- IDK  if it is write or wrong, more likely to be a wrong practice to hook/unhook every time but it gets the job done. The primary reason to refresh hook is to prevent app hanging (not responding to the key press) after few clicks on the WPF button.

void _listener_OnKeyPressed(object sender, KeyPressedArgs e)
        {
           
          _listener.UnHookKeyboard();
          _listener.HookKeyboard();
        }

Following is the video from Dylan Currier  on Low Level Keyboard Hook in C# / .NET"


Wednesday, May 24, 2017

When to use ArcGIS Online to publish geospatial data: CASE STUDY EUROPEAN ENVIRONMENT AGENCY

Be The First To Comment
ArcGIS Online is a workspace and a web platform for creating and sharing maps. It is possible to upload your data, create a layer or a map, define the extent, set some visualization options, assign permissions to your layer or map, share, and create web mapping applications or story maps. For information about the other capabilities please visit http://doc.arcgis.com/en/arcgis-online/.

The ArcGIS online platform is designed to host small datasets, for example demographic datasets. The datasets uploaded to ArcGIS online are relatively small in size, and should not exceed 1-2MB, or around 5000 records. This is to keep the agencies costs down and keep in line with our ArcGIS online pricing plan. It is for this reason that ArcGIS online should not be used to host large datasets, and tiled image services must NOT be uploaded to ArcGIS online. To publish bigger datasets and image services, please refer to the ArcGIS Server.

Source: http://discomap.eea.europa.eu/map/giseionet/Publishing_data_to_the_web_with_ArcGIS_Online.pdf
 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me