ThinkGeo.com    |     Documentation    |     Premium Support

SQL Server 2008 layer yields "Unlicensed"?

Hi all,


I'm a new user with MapSuite, and is currently evaluating it for use with SQL Server 2008 Spatial. I downloaded and installed it today.


In my VM running Windows 2003, I've installed SQL Server 2008 Enterprise Evaluation version, and added a small feature layer table, that I know works (been evaluating other software).


In VS 2008 I've built a small web application, that creates a mapper with this layer. I've used the online demo as a guide line.


However, all returned tiles just displays the word "Unlicensed" !


I'm not aware whether this "license" refers to SQL or MapSuite ? And if either, what's causing it to fail ?


I'm using the "sa" account to access SQL Server, who also owns the database in use, so permissions ought not be a problem.


--


Best regards


Lars I. Nielsen


GisPro.dk



Ah, my novice status shows :-)


"Unlicensed" was from MapSuite, my SQL 2008 layer doesn't show at all :-/


I suspect it has something to do with it being a projected dataset, it's in EPSG:25832.


How does one reproject the map to suit this projection, or reproject the data to suit the map display ?


/Lars



Lars, 
  
   You guessed right that the ‘unlicensed’ is form Map Suite during the trial.  As to getting it to display on the map if the data is in anything other than decimal degrees then you need to make sure to set the map unit of the map to either feet or meters.  It will be something like Map1.MapUnit = GeographicUnit.Meters or something along this lines.  I would do this as the first line of code.  Many of the math routines have different code paths for decimal degrees versus feet and meters. 
  
   The next step is I would make sure that you have a current extent setup for the map.  To do this I would do something like create your layer and then call the layer.Open and then call the Layer.GetBoudningBox and set the Map1.CurrentExtent to this.  Also don’t forget to call the layer.Close after that.  This will make sure the map is zoomed to the right place. 
  
   Another thing you can do to test the connectivity is when the layer is opened you can call an API like Layer.QuieryTools.GetAllFeatures and this will return back all the features.  You can look at the results to make sure everything is connecting properly.  It might be good to in the future have a test connection method.  I will add this to our task system. 
  
   You will also need to make sure you have some styles set in the zoom levels to determine how the records will draw.  I highly suggest you check out the code in the How Do I samples for SQL Server.  There should be everything you need to get started.  Of course in that sample we use decimal degree data so remember the stuff above.  
  
   If you still can’t get it working but it does connect fine then send me you complete code and I can take a look if you are missing anything. 
  
 One last thing is that if all of your data is in the same projection then you don’t need to do any re-projection.  This is only necessary if you want to mix and match data that are in different projections.   
  
 David

Thanks David,


Your reply got me a lot further along the road, but alas, not across the finishing line.


I can get the number of features from my SQL 2008 based dataset, so the connection is apparently valid. But the dataset still doesn't show up as a layer in my map.


All my own data is (and will be) in meter based projection, in UTM zone 32 north on ETRS89, i.e. EPSG:25832. But I only have it as MapInfo TAB, with possibility to transfer it to SQL 2008. So I'm utilizing some of the sample shape files that came with the installation.


Whenever I set MapUnit to "meters", my world country map (...\ThinkGeo\Map Suite Web Evaluation Edition 3.0\Samples\CSharp Samples\SampleData\World\cntry02.shp) disappears, even though I apply a projection object to convert it to utm 32n.


I suspect the problem lies in a faulty assumption about what projection the above sample dataset is in. I've tried wgs84 latlong, wgs84 mercator, and even wgs84 "google", but all fail to produce the layer onto my map. I've even used GetBoundingBox from the converted sample layer to set the mapper viewport, but nothing shows.


If I need to post code to you, should I do it here on the forum ?


 



Further to my post:


I tried to set my map to meters, and set the viewport to a sensible Utm 32 coordinate range:



        
  • X = 300,000 - 800,000 meters (300-800 km)

  •     
  • Y = 6,000,000 - 6,500,000 meters (6,000-6,500 km)


However, I'm met with a tile renderer runtime error "side location conflict", claiming that at least one of the numbers are NaN. See below JPEG for how it appears in my map.



Utm has Y values from 0 up to 10,000 km (= 10,000,000 meters). Is MapSuite not capable of handling such values ?


 



Lars, 
  
   I think I understand what you are doing but I want to make sure. 
  
 1.You have data in SQL Server.  You can connect to it and you mentioed you can get the record count right?  Could you try to do a GetAllFeatures from the QueryTools and just make sure the X & Y values that are coming back is in the rage you expect.  This is just to be sure. 
  
 2.You are taking the world data that comes with the evaluation and trying to project it to you UTM zone for display. 
  
 3.You have the Map.MapUnit set to meters. 
  
 4.You have the Map.CurrentExtent set to a reasonable value in meters. 
  
 Ok the first thing that might be throwing you off is the projecting of the world data.  This is a bad idea because some points of the world data are at the bounds like 180 or -180 etc.  When we project into UTM to a specific zone then points outside of the zone start to get really strange as you move further outside of its intended usage area.  I think this is causing the ‘nan’ issue as this is what Proj4 will return back if you try to project points that it considers invalid.  UTM uses a cynlinder and move it based on the zone you pick.  Points where the cylinder touches the earth as a sphere are very accurate but as you go further way things start to go wrong. 
  
   I would suggest not using the earth and trying with with your UTM data from SQL Server.  We should try and get that working first.   
  
 There are a few thing I need to make sure of. 
  
 1.Are you setting some styles for the SQL Layer?  I mean if they are lines or polygon have you set a color for them and a thickness? 
 2.Are you adding the Layer to the StaticOverlay.Layers on the map control? 
 3.Are you using CustomOverlays at all? 
 4.When you choose a style for a zoom level are you picking zoom level 01 and then adding the line that is like ZoomLevel01.ApplyUntilZoomLevel = ApplyUntil.ZoomLevel20?  This is to make sure the style is applied at all zoom levels no matter how far you zoom in or out.  Of course you want to change this later 
  
 Could you share the code you are using to load the map and set the styles?  All you can share would be helpful. 
  
 Another way you could do it is to call that GetAllFeature to get all of them and then create an InMemoryFeatureLayer and add all the features to it through the InternalFeatures dictionary.  You could then add this layer to the map.  This would bypass the SQL all together and focus in on just the drawing part.  I think you are just missing like one crucial line of code.  I suggest you look at the SQL sample as well to see if you are missing anything.   
  
   What we tried to do with the sample is remove anything that is not important to get a good signal to noise ratio.  If the sample has the line more than likely you will need it as well. 
  
 David

Hi David,


I've really just taken snippets from two of your sample apps, and I think it's all there. I'm just trying to display my projected SQL 2008 data in the map any way I can.


I understand what you're saying about projections going beyond their definition. However, as I wrote, all my data's in a projection, usually utm 32n. LatLong and other world projections are simply not relevant for my usage, so I need the software to be able to handle such, and I assume it does.


But even though I remove the "world" layer, and only add my projected data (without any re-projection), using a fixed viewport that I know corresponds to my data, it doesn't show up in my map.


I added the call to GetAllFeatures as suggested, although GetCount ought to be ok. And sure enough, it returns a valid X,Y.


The stripped down code's like this (hope it renders correctly):


 Imports ThinkGeo.MapSuite.Core Imports ThinkGeo.MapSuite.WebEdition  Partial Public Class _Default     Inherits System.Web.UI.Page      Const CONNECT_SQL As String = _         "Data Source=127.0.0.1,1433;Network Library=DBMSSOCN;Initial Catalog=MAPS;User ID=sa;Password=helledusseda;"      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load         If Not IsPostBack Then             Map1.StaticOverlay.TileType = TileType.MultipleTile             Map1.EnableViewState = True             TextBox1.Text = "Hello World"              Map1.MapUnit = GeographyUnit.Meter              Dim KomLyr As MsSql2008FeatureLayer = _                         New MsSql2008FeatureLayer(CONNECT_SQL, "NyKommuner", "ID")              KomLyr.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country2             KomLyr.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20              Map1.StaticOverlay.Layers.Add("Kommuner", KomLyr)              KomLyr.Open()              Dim cols As New Collection(Of String)             Dim fts As New Collection(Of Feature)              cols.Add("KOMMUNENAVN")             cols.Add("KOMNR")             fts = KomLyr.QueryTools.GetAllFeatures(cols)             TextBox1.Text = _                         "X = " + fts(2).GetShape.GetCenterPoint.X.ToString() + _                         ", Y = " + fts(2).GetShape.GetCenterPoint.Y.ToString()              KomLyr.Close()              Map1.CurrentExtent = New RectangleShape(300000, 6500000, 800000, 6000000)         End If     End Sub End Class 


After it's run, the textbox shows this text: "X = 717829,692407861, Y = 6183640,91546655", which is as expected.


This is an snippet of my script to create the SQL 2008 based shapes table:


Create Table [NyKommuner] (

  [KOMMUNENAVN] varchar(40),

  [REGION] varchar(40),

  [KOMNR] int,

  [feature] geometry,

  [ID] [int] IDENTITY(1,1) NOT NULL,

    CONSTRAINT [PK_NyKommuner] PRIMARY KEY CLUSTERED 

    ([ID] ASC)

    WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)

);

...

Insert Into NyKommuner ([KOMMUNENAVN],[REGION],[KOMNR],[feature]) 

    Values ('Gladsaxe','Hovedstaden',159,geometry::STGeomFromText('POLYGON((715740 6186782, ... ,715740 6186782))',25832));

...


Hope all this will help you help me along.


 



Posted By Lars I. on 01-29-2009 12:47 PM 


(hope it renders correctly)



 Well it didn’t. Is it my Firefox that “eats” all the missing CR’s ? It looked all right in source view, at least until I left it.




Jan. 31st. Nope, just tried it with IE: same problem.


I paste my code between the “code” tags in source view, and all look fine. When I leave source view, all my code line are put into a single row.


Please advise on to how this works. I’ve read the “how to post source code”, and are doing everything as explained.


 



Posted By Lars I. on 01-29-2009 12:47 PM 

Hi David,


I’ve really just taken snippets from two of your sample apps …


 





Hi David,


Have you given up on me ? :-)


I can send the full SQL insertion script if you need to test my data set.


 



Hi David,


Ah, I think I figured it out. When pasting in normal view instead line breaks are appended to each line. It does, however, also split the code into multiple "code" segments, every time it sees a double-CrLf. Fixed that in my trusted external text editor.


Here's the latest version of my test project, that still doesn't display the SQL 2008 layer.


Imports System.Collections.ObjectModel

Imports ThinkGeo.MapSuite.Core

Imports ThinkGeo.MapSuite.WebEdition



Partial Public Class _Default

    Inherits System.Web.UI.Page



(rest deleted)


HTH


--


Alas, it didn't work after submission :-(  Deleted most of the ugly thing.


Can't I just send the files to you by email ?


 



Lars, 
  
   I haven’t forgotten about you.  Things have been very busy here lately and I was unable to get your source.  When you past in the source on the discussion forum you need to make sure to the following. 
  
 1.Make sure you hit the reply button and NOT use the quick reply. 
 2.Write your comments when you are not in the source area then switch to Source view just to paste in your code. 
 3.When you are in the reply screen you need to make sure you clock on the Source button when you paste in your code.  This prevents the editor from adding all the line breaks. 
 4.Paste your code ask the last step and  then hit submit, do not go back to the regular view. 
 5.One thing I so is always take my source and comments and paste them into notepad to make sure any formatting is removes such as what Word will add to it. 
  
 I hope this helps.  Can you attach the file as a .txt file to the issue?  You can always send the source to support@thinkgeo.com and ask them to forward it to Ben & David. 
  
 David

Hi David,


I sent you my source code and the sql table creation script by email.


I've experimentally tried to add a points layer on top of the polygon layer, but this doesn't show either.


I've eliminated any potential "regional settings" by switching to US English setup for numbering format.


The only thing I can think of now, is some sort of missing dependency. My install's completely clean, i.e. no prior MapSuite installations exists on my test machine.


I hope the files I sent will enable you to find the display problem.


 



Hi David,


Success! I found the problem.


When creating my sql script to populate the sql 2008 tables, I specify the correct epsg code for each spatial record, saving it directly within the spatial feature. To make it "projection-aware" or something.


MapSuite apparently mishandles this information, and probably performs some sort of re-projection of its own.


When I changed the epsg numbers (25832 or 23032 in this case) to 0, it worked, and my data displayed nicely.


Can you find an explanation as to in what way MapSuite handles explicit record based epsg setting ?


 



Lars, 



Currently we recognize the srid from constraint; the epsg settings will work fine after adding a constraint with the following statement to your database: 



ALTER TABLE [tablename] ADD CONSTRAINT [enforce_srid_geometrycolumn] CHECK ([feature].STSrid = 25832); 



This is a bug I think, we are going to enhance it and read the srid info from feature, then it will work with your database. Thanks for pointing it out.



Ben.