Thursday, 20 January 2011

Some notes on ArcGIS and associated technologies

I’m getting started with ArcGIS so I need to keep some notes. NB: This post is just an aide-mémoire for me as I get started so nothing is covered in any detail.

What is Esri?

Esri is a company providing Geographic Information System (GIS) software and geodatabase management applications. They are based in California and have about 30% of the GIS software market (see http://en.wikipedia.org/wiki/Esri).

What is the APDM?

APDM (ArcGIS Pipeline Data Model) is an open standard for storing geographical data associated with pipelines:

The ArcGIS Pipeline Data Model is designed for storing information pertaining to features found in gathering and transmission pipelines, particularly gas and liquid systems. The APDM was expressly designed for implementation as an ESRI geodatabase for use with ESRI's ArcGIS and ArcSDE® products. A geodatabase is an object-relational construct for storing and managing geographic data as features within an industry-standard relational database management system (RDBMS).” - http://www.apdm.net/

What is ArcSDE?

ArcSDE technology is a core component of ArcGIS Server. It manages spatial data in a relational database management system (RDBMS) and enables it to be accessed by ArcGIS clients.” - http://www.esri.com/software/arcgis/arcsde/index.html

ArcSDE technology serves as the gateway between GIS clients and the RDBMS. It enables you to easily store, access, and manage spatial data within an RDBMS package…

ArcSDE technology is critical when you need to manage long transactions and versioned-based workflows such as

* Support for multiuser editing environments
* Distributed editing
* Federated replicas managed across many RDBMS architectures
* Managing historical archives

The responsibility for defining the specific RDBMS schema used to represent geographic data and for application logic is retained in ArcGIS, which provides the behavior, integrity, and utility of the underlying records.” - http://www.esri.com/software/arcgis/geodatabase/storage-in-an-rdbms.html

What is a geodatabase?

“The geodatabase is the common data storage and management framework for ArcGIS. It combines "geo" (spatial data) with "database" (data repository) to create a central data repository for spatial data storage and management.” - http://www.esri.com/software/arcgis/geodatabase/index.html

Basic terms and concepts

There are four fundamental types upon which geographic representations in a GIS are based:

  • Features (collections or points, lines, and polygons)
    • Representations of things located on or near the surface of the earth.
    • Can be natural (rivers, vegetation, etc).
    • Can be constructions (roads, pipelines, buildings, etc.).
    • Can be subdivisions of land (counties, political divisions, land parcels, etc.).
    • Most commonly represented as points, lines, and polygons.
  • Attributes (descriptive attributes of features)
    • Managed in tables based on simple relational database concepts.
  • Imagery
    • Imagery is managed as a raster data type composed of cells organized in a grid of rows and columns.
    • In addition to the map projection, the coordinate system for a raster dataset includes its cell size and a reference coordinate (usually the upper left or lower left corner of the grid).
    • These properties enable a raster dataset to be described by a series of cell values starting in the upper left row.
    • Each cell location can be located using the reference coordinate, the cell size, and the number of rows and columns.
  • Continuous surfaces (such as elevation)
    • A surface describes an occurrence that has a value for every point on the earth.
    • Surface elevation is a continuous layer of values for ground elevation above mean sea level.
    • Other surface type examples include rainfall, pollution concentration, and sub-surface representations of geological formations.

See the ArcGIS Desktop Help file for further details.

GIS data structures

Features, rasters, attributes, and surfaces are managed using three primary GIS data structures:

  • Feature classes
  • Attribute tables
  • Raster datasets

Map Layer Types GIS Datasets
Features (points, lines, and polygons) Feature classes
Attributes Tables
Imagery Raster datasets
Surfaces

Both features and rasters can be used to provide a number of alternative surface representations:

  • Feature classes (such as contours)
  • Raster-based elevation datasets
  • TINs built from XYZ points and 3D line feature classes

In a GIS datasets hold data about a particular feature collection (for example, roads) that is geographically referenced to the earth's surface. A dataset is a collection of homogeneous features. Most datasets are collections of simple geographic elements.

Users work with geographic data in two fundamental ways:

  • As datasets (homogeneous collections of features, rasters, or attributes)
  • As individual elements (e.g. individual features, rasters, and attribute values) contained within each dataset

Datasets are:

  • The primary inputs and outputs for geoprocessing.
  • Datasets are the primary means for data sharing.

 

See also

There’s some good basic information on GIS systems on the Ordinance Survey website: http://www.ordnancesurvey.co.uk/oswebsite/gisfiles/index.html

Thursday, 20 January 2011

Tuesday, 18 January 2011

Log on as a batch job in Windows Server 2008

Problem

When creating a scheduled task on Windows Server 2008 I needed to assign a local user to run the task. For this to work the user must be given “Log on as a batch job” privileges.

Solution

1. Administrative Tools > Local Security Policy
2. Security Settings > Local Policies > User Rights Assignment
3. Find and double-click on the “Log on as a batch job” policy.
4. Add User or Group…
5. Add the user and click OK.

untitled

Multiple X.509 certificates found

Problem

I was configuring a WCF service to use SSL and had created and installed a self-signed certificate. The WCF service configuration looked something like this:

<serviceBehaviors>
  <behavior name="EnquirySubmissionServiceBehavior">
    <serviceMetadata httpsGetEnabled="true" />
    <serviceDebug includeExceptionDetailInFaults="true" />
    <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="SqlRoleProvider" />
    <serviceCredentials>
      <serviceCertificate findValue="CertificateNameHere" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
    </serviceCredentials>
  </behavior>
</serviceBehaviors>

When trying to access the service metadata in a browser I received an error stating that multiple X.509 certificates had been found using the given search criteria.

Solution

The solution was to change the configuration to use an alternative method to find the certificate. In this case I used FindByThumbprint and provided the certificate thumbprint. To obtain the thumbprint do the following:

1. Start > Run > mmc
2. File > Add/Remove snap in…
3. Find and add Certificates (local machine).
4. Find the certificate and double-click on it.
5. In the pop-up dialog scroll to Thumbprint and click on it to view the value.
6. Copy the thumbprint value and remove spaces.

untitled

I then changed the WCF service configuration to look something like this:

<serviceBehaviors>
  <behavior name="EnquirySubmissionServiceBehavior">
    <serviceMetadata httpsGetEnabled="true" />
    <serviceDebug includeExceptionDetailInFaults="true" />
    <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="SqlRoleProvider" />
    <serviceCredentials>
      <serviceCertificate findValue="46677f6006fb15fe64e5f394d1d99c22f3729155" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" />
    </serviceCredentials>
  </behavior>
</serviceBehaviors>

Enable 32-bit application pools on IIS7

The problem

I ran into the situation where a WCF service had a reference to sever 3rd party components. One of the components itself actually had a reference to some ancient 16-bit code. The WCF service was hosted in IIS7 on a 64-bit machine and used Unity to resolve dependencies.

As Unity tried to resolve dependencies I kept getting an error that looked a bit like this:

Unexpected exception thrown by call to <service type here>: Resolution of the dependency
failed, type = "<service contract interface here>", name = "(none)".
Exception occurred while: Calling constructor <type that failed construction>.
Exception is: FileNotFoundException - Could not load file or assembly <assembly name here>,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=<key here>' or one of its dependencies. 
The system cannot find the file specified.

 

The solution

The solution was to configure the application pool that the service was using to allow 32-bit assemblies.

1. View application pools and select the appropriate pool from the list.
2. Choose ‘Advanced settings…’ from the menu on the right.

untitled

3. Set ‘Enable 32-Bit Applications’ to True.
4. Click OK.

Untitled2

Friday, 14 January 2011

IIS7 and WCF MIME types

Problem

I needed to deploy a WCF service to IIS7 running on windows server 2008. The service was accessed via a .svc file but upon calling it from a browser an error was reported stating that the .svc extension was not recognised.

Solution

The solution was to reregister the WCF Service Model with IIS by running ServiceModelReg.exe:

"%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r -y

The flags used were:

Flag Description
-r Re-registers this version of WCF and updates scriptmaps at the IIS metabase root and for all scriptmaps under the root. Existing scriptmaps are upgraded to this version regardless of the original versions.
-y Do not ask for confirmation before registering or re-registering components.

After reregistering the WCF Service Model the .svc extension was correctly installed. Note that IIS7 did not require a restart.

Full details of ServiceModelReg.exe and all its flags can be found here: ServiceModel Registration Tool (ServiceModelReg.exe)

Friday, 14 January 2011,

Generating temp SSL certificates for development

Update 01/03/2014

If you’re using IIS 7 there is a quick way to create self-signed certificates. Details can be found in this post: Create a self-signed certificate for development in IIS 7.

If you still want to know about the manual method read on.

Original post

I needed to generate an SSL certificate for testing a WCF service which needed to be secure. Not wanting (or having the budget for) a real SSL certificate I elected to generate my own. The following batch file contains the main ingredients:

@echo off

echo Step 1 - Creating a self-signed root authority certificate and export the private key.
echo You will be prompted to provide a password to protect the private key.
echo The password is required when creating a certificate signed by the root certificate.
echo ===================================================================================
makecert -n "CN=RootTempCA" -r -sv RootTempCA.pvk RootTempCA.cer

echo Step 2 - Create a new certificate signed by a root authority certificate
echo ========================================================================
makecert -sk domain.to.secure -iv RootTempCA.pvk -n "CN=domain.to.secure" -ic RootTempCA.cer -sr localmachine -ss my -sky exchange -pe

The domain.to.secure should be replaced to match the environment (this could be localhost, the machine name, whatever you need). Step 2 should install the certificate into the certificate store – no need to do it manually.

The makecert flags used above breakdown as follows:

Flag Step Description
-n subjectname 1, 2

Specifies the subject name. The convention is to prefix the subject name with "CN = " for "Common Name".

-r 1

Specifies that the certificate will be self-signed.

-sv privateKeyFile 1

Specifies the file that contains the private key container.

-sk subjectKey 2

The location of the subject's key container that holds the private key. If a key container does not exist, one is created. If neither of the -sk or -sv options is used, a key container called JoeSoft is created by default.

-iv issuerKeyFile 2

Specifies the issuer's private key file.

-ic issuerCertFile 2 Specifies the location of the issuer's certificate.
-sr location 2

Specifies the subject's certificate store location. location can be either currentuser (the default) or localmachine.

-ss store 2

Specifies the subject's certificate store name that stores the output certificate.

-sky keytype 2

Specifies the subject's key type, which must be one of the following: signature (which indicates that the key is used for a digital signature), exchange (which indicates that the key is used for key encryption and key exchange), or an integer that represents a provider type. By default, you can pass 1 for an exchange key or 2 for a signature key.

-pe 2

Marks the generated private key as exportable. This allows the private key to be included in the certificate.

Because this process creates a self-signed certificate if you access the service from a remote machine you will likely run in to problems because the certificate was issued by an unknown Certification Authority. To get around this you need to import the root certificate into the trusted root certificate store on the client machine. I find it best to import the certificate using a Personal Information Exchange (pfx) file. To create the .pfx run the following:

pvk2pfx.exe -pvk RootTempCA.pvk -spc RootTempCA.cer -pfx RootTempCA.pfx -po password_here

References

 

See also

Thursday, 13 January 2011

Creating shortcuts to Remote Desktop to a specific machine

I like using Launchy to open and close applications. This includes opening Remote Desktop but it’s nice to be able to jump straight to a Remote Desktop session on a particular machine by simply typing the machine name into Launchy.

The way I do this is:

  1. Create a folder under C:\Documents and Settings\<username>\Start Menu\Programs\ called Shortcuts.
  2. Add this folder to the Launch catalog using the Launchy options dialog.
  3. Create a new shortcut in the new folder.
  4. For the ‘Location of the item’ type %windir%\system32\MSTSC.EXE /v:MACHINE_NAME where MACHINE_NAME is replaced with the name of the machine you want to Remote Desktop to.
  5. For the name of the shortcut use the machine name.
  6. Save the shortcut and get Launchy to rescan its catalog.

 

untitled

Untitled2


Now, by tying the machine name into Launchy you can immediately open a Remote Desktop session to the machine.

Untitled3