ThinkGeo.com    |     Documentation    |     Premium Support

Shapefile Type and Using *.PRJ Files to programatically set the projection

Hi,


I'm building a desktop application that consumes a WMS Web service that I built using the services edition and the World Map Kit for my base maps.  This is working great and now I want to allow my users to overlay shape files on top of the world map kit base map so they can easily add new features on top of the map.


What I'm planning on doing is adding a little Add Layer Wizard that will allow the user to browse to the shapefile they want to add and then prompt them to pick a projection and set some basic style information but before I get started coding this up I have a few questions.


Question #1. 


The shapefiles that the user will be adding on top of the world map kit could possibly be in all different types of projections.  For now my application is limited to the United States so the projections will most likely be variations of UTM and StatePlane.  My first thought was have the wizard driven off a config file that has a list of all the likely projections that the shapefiles could be in and allow the user to pick the correct projection and then reproject it on the fly to WGS84 Long/Lat so it would align with he world map kit.  However I would like to do this step programatically if possible, since some of my users may not understand projection and may pick the wrong one from the list.  All of my shapefiles have a *.prj along with them that seems to contain the projection information.  For one of my files that was already in WGS84 Long/Lat the file contained the following string when I opened it in notepad:


GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]


My question is, is there any Map Suite API's that will read this file and allow me to programatically set the projection instead of having the user pick it?  If not does this string conform to any standard or have any mapping to your projection engine so I can write my own logic?  Any help would be greatly appreciated!


Question #2


OK, after the user set the path to the shapefile and the projection is taken care of I need to allow them to set the style and labeling for the shapefile layer.  My thought was to have a very simple UI just like what you have in the Map Suite Explorer but I want to make one improvement.  Since I want to make it as simple as possible I want to programmaticlly display either the AreaStyle, Point Style or Line Style settings, I don't want the end user to have to choose which style they need to set because I think a lot of them will get confused.  Is there a property I can query off of the ShapeFileFeature layer to see if it's an Area, Line or Point shapefile?  If so this would make it easy to display the correct style dialog.


Thanks for all your help!


 


 


 


 


 


 


 


 


 


 



Clint, 


We don’t support prj files for now. We are working on that but I’m not sure when we can have the solution. Those texts are short edition of Projection WKT and we are using proj4 which uses EPSG number to represent a projection. I’m not very sure how to transform between the two. L  It would be appreciated if any one can let me know.


 


We will add an API to get the ShapeFileType. One thing want to make it clear is that ShapeFile has 14 types (Page 4 of the esri.com/library/whitepapers/pdfs/shapefile.pdf), you need to have more judgment to see if it’s a point, line or polygon.


 


For now to work around, you can get one feature from a shape file and call the method GetWellKnownType(). As every feature in one shape shares the same type, you can get the type of a shape file from the type of a feature. That might not work for some special cases (the feature you picked is Null for example) but that's rare.


 


Ben.