Tuesday, May 31, 2016

Code Snippet: Set default database schema in Nhibernate SessionFactory

Be The First To Comment
1:  //Setup oracle database connection and connection pool  
2:    public class OracleConnectionManager  
3:    {  
4:      private static string _userName;  
5:      private static string _password;  
6:    
7:      public OracleConnectionManager(string userName, string password)  
8:      {  
9:        _userName = userName;  
10:        _password = password;  
11:      }  
12:    
13:      private static ISessionFactory _sessionFactory;  
14:      private static ISessionFactory SessionFactory { get  
15:        {  
16:          if(_sessionFactory == null)  
17:          {  
18:            var connectionString = DatabaseConnections.GetOracleConnectionsString(_userName,_password);  
19:              
20:            //Nhibernate Oracle database configuration  
21:            var configuration = new Configuration();  
22:            configuration.DataBaseIntegration(db =>  
23:            {  
24:              db.ConnectionProvider<NHibernate.Connection.DriverConnectionProvider>();  
25:              db.Dialect<NHibernate.Dialect.Oracle10gDialect>();  
26:              db.Driver<NHibernate.Driver.OracleDataClientDriver>();  
27:              db.ConnectionString = connectionString;  
28:             });  
29:    
30:            // Setup default schema  
31:            configuration.SetProperty(Environment.DefaultSchema, "DB_SCHEMA_NAME");  

Monday, May 30, 2016

Open Source Cloud GIS System Setup with Amazon EC2 and Geoserver

Be The First To Comment
Follow these steps to set up the open source cloud based GIS mapping system.

1. Create an Amazon Web Services (AWS) account. You can find instructions for this step in the EC2 Getting Started Guide.

3. Create an Amazon EC2 instance. Instructions are also in the EC2 Getting Started Guide. When choosing an AMI make sure you choose a Windows server with IIS (and ASP.NET) already installed.

4. Connect to your Windows EC2 instance and install GeoServer. You can download GeoServer here. There are multiple setups available. Use the Windows installer. The instructions for the install are here.

5. Copy GIS data and configure map layers. The GeoServer user's manual will guide you through the steps of configuring GeoServer.

6. Start GeoServer on the EC2 instance server.

7. Seed the layers in GeoWebCache on the server. Instructions for this are here. Note that jpeg tiles are smaller than png and the default for base layers. Also png are better quality and will always be used for overlays because they can be transparent and overlays need to support transparency. Seed all layers for zoom levels 0 to 10 for EPSG:4326. If it is a base layer, seed it with jpeg files. If it is an overlay layer, seed it with png files.

Thursday, May 26, 2016

Setting up automatic product or build version increment using JENKINS for .NET projects

Be The First To Comment
Steps for setting up automatic product or build version increment using JENKINS Continious Integration server and Visual Studio for .NET projects

Part A - Configure Visual Studio Solution

1. Copy the "AssemblyInfo.cs" from your project solutions and rename into "AssemblyInfo.cs.template"



2. Add a file called "AssemblyInfo.cs.template" and replace with these two lines:
             [assembly: AssemblyVersion("#VERSION_NUMBER#")]
             [assembly: AssemblyFileVersion("#VERSION_NUMBER#")]

3. In project properties, insert this pre-build command:
     "$(SolutionDir)builder-scripts\templates\pre-build\Stamper.exe" "$(ProjectDir)\"



4. Put the "builder-scripts" folder into your solution folder. Builder scripts source


Code snippet: Unzip the zip file in C# using DotNetZip

Be The First To Comment
DotNetZip is a FAST, FREE class library and toolset for manipulating zip files. Use VB, C# or any .NET language to easily create, extract, or update zip files.

1:  public static void DeCompressFile(string zipFilePath, string extractPath)  
2:      {  
3:        string zipToUnpack = zipFilePath;  
4:        string unpackDirectory = extractPath;  
5:        using (ZipFile zipfiles = ZipFile.Read(zipToUnpack))  
6:        {  
7:          // Here, we extract every entry, but we could extract conditionally based on entry name, size, date, checkbox status, etc.   
8:          foreach (ZipEntry e in zipfiles)  
9:          {  
10:            e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);  
11:          }  
12:        }  
13:    
14:        Console.WriteLine("Status: Done extracting the zipped Archive");  
15:      }   

Code snippet: Read data from Access Database in C#

Be The First To Comment
Read data from Access Database in C#

1:  private static void ReadFromAccess(string accessDbPath)  
2:      {  
3:        string connection = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= {0}",accessDbPath);  
4:        using (OleDbConnection con = new OleDbConnection(connection))  
5:        {  
6:          try  
7:          {  con.Open();  
8:            OleDbCommand cmd = new OleDbCommand("SELECT * FROM Table_NAME", con);  
9:            OleDbDataReader reader = cmd.ExecuteReader();  
10:    
11:            while (reader.Read())  
12:            {  
13:              Console.WriteLine(reader.GetString(0));  
14:            }  
15:    
16:          }catch(Exception ex)  
17:          {  
18:            Console.WriteLine(ex.Message);  
19:          }finally  
20:          {  
21:            con.Close();  
22:          }  
23:        }  
24:      }  

Thursday, March 3, 2016

Esri Leaflet Dynamic TileLayer Plugin Example

Be The First To Comment
While working in one my Esri-Leaflet based application, I am stumbled on rendering dynamic map layers on tiled basis. Esri leaflet-api does the perfect job on non-tiled layer display but L.esri.DynamicMapLayer, doesn’t provide the tiled dynamic map layers. Looking around I came across the Tiled dynamic layer plugin for esri-leaflet, for displaying the DynamicMapLayer in tiled mode.

Here I have created both non-tiled and tiled DynamicMapLayer version for comparison using plain esri-leaflet and esri-leaflet with plugin.


Gallery: Animated Dendrograms using D3.js

Be The First To Comment
Lists of animated dendrograms using D3.js
1) Dendrogram with root to node selected path highlight, zoom and pan
2) Species sunburst
3) Species wheel with zoom pan feature
4) Collapsible dendrogram with root to node selected path highlight plus zoom/pan

How to display HTML5 applications from Github Gist to bl.ocks.org?

Be The First To Comment
The http://bl.ocks.org is a simple viewer for HTML/CSS/JavaScript code examples hosted on Github Gist, which is built by Mike Bostock. In other words, blocks.org is a tool which will convert the Gist code into the format you see in bl.okcs.org allowing you to view HTML/ CSS / JavaScript applications directly from GitHub/Gist. GitHub is a web based version control and source code repository and Gists are a great way to share your source code among the peers.

Gists could be anything, but in HTML/JavaScript perspective, it could be a beautiful visualization using d3.js, interactive web map using Leaflet or Openlayers or ESRI Javascript API, and web map with WMS layers etc. Gists can share single files, parts of files, or full applications.

If you have built a beautiful visualization using HTML/JavaScript and want to view on blocks.org. 
Here is how to do this.

Wednesday, January 6, 2016

Conference: MidAmerica GIS Symposium (MAGIC) 2016 Symposium

Be The First To Comment
The 2016 Symposium will be held at the Overland Park, KS Convention Center April 24 - April 28, 2016 in Overland Park, Kansas. The conference hotel, the Overland Park Sheraton is adjacent to the Convention Center.
Why did we chose Overland Park? Overland Park is one of the fastest growing areas in the country. The OP Convention Center is very spacious - offering our Planning Committees ample opportunity to bring you new learning experiences! Additionally, we've listened to your concerns with previous location logistics:
  • Parking: It's free and there is plenty of it!
  • Internet: It's also free EVERYWHERE including the guest rooms, meeting rooms, and Exhibit Hall!
  • The Gym: It's free too!
  • Location: Downtown Kansas City can be intimidating. The Overland Park Convention Center is extremely easy to get to, and is right off a major highway. Additionally, the area is hopping with new entertainment and shopping districts, restaurants and museums!
GIS covers such a broad range of subjects, applications and types of people that use it, that developing a conference program that meets everyone's needs is a challenging task. Even more challenging is an attendee trying to figure out exactly which sessions or topics will be most interesting and helpful. MAGIC 2016 is intended to focus the content of the presentation options into a program specifically geared to each attendee's needs.

Nhibernate criteria API - select from multiple tables

Be The First To Comment
If you ever worked with relational databases then higher chances are you already worked with sub queries. Some time while working with Nhibernate you get yourself into some situation where you need sub query to do some lifting for you. In NHibernate criteria API you can do the sub query usingDetachedCriteria and Subqueries classes. As the name suggests DetachedCriteria helps you define your sub query criteria while Subqueries class help you create sub query criterion object using detached criteria object.

In order to demonstrate sub query implementation lets consider an example. Suppose we have three entities Order, OrderItem and Product where one order can more have more then one order items while one order item may be linked to a product. If we need to do a query where we need to list all those order items which are linked to products and have price greater then $100. Also the products must be the ones marked as special in system. The SQL for such query may be something like below

SELECT * FROM OrderItem AS OI 
WHERE OI.Price > 100 AND OI.ProductId IN ( SELECT P.ProductId FROM Product WHERE P.IsSpecial = 1 )
 

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

About Me