ThinkGeo.com    |     Documentation    |     Premium Support

WMS to get data from application server

Hello,


we have to display raster data (geo tiff) with Map Suite Desktop Edition on the client side. The raster data files are not stored on the client but on our application server. The communication between Client and App-Server is carried via web service.


For this reason we supposed to create a Web Map Service that is hosted on our App-Server und display the data via WmsRasterLayer on the client side.


Is  there any sample code where I can see how to create the WMS to meet the requirements so I can use it with WmsRasterLayer?


Thanks



Thomas, 
  
   My suggestion is that if you already have a web service that will server up images then there is no need to go the WMS route.  I suggest you create your own Layer or Overlay.  Override the DrawCore and then in there make your web service request and paint the request on the canvas.  We have creating a learning video on this at the link below.  There are a number of samples and 50 minute video on how to do this.  I think this way will be much faster and lower overhead. 
  
 gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/16/aft/5736/afv/topic/Default.aspx 
  
 David

OK David, 
  
 that sounds good to me. 
  
 We also have other file based elements e.g. shapefiles they have to be displayed on client but they are stored on Application Server. 
 What do you suggest to get best performance (keep in mind we have about 50-100 Client PC’s): 
 - Transfer shapefile(s) to client via web service and open them with shapefilefeatureLayer? 
 Or 
 - Convert shapefile to table in MS-SQL-Server 2008 database on Application Server and use MSSql2008FeatureLayer with my own Feature Source to get the data via web service? 
 Or 
 - Convert shapefile to table in SQL-Server storing shape data as WKB in binary-column and use my own Layer and Featur Source to get the data 
 Or 
 … any other suggestion 
  
 Thanks 
 Thomas 


Thomas, 
  
   You didn’t mention all of those other layers before. :-)  In that case it all depends on the total size of the data, if they are small you could transfer them to the client.  At this point if there is quite a bit of data I would not suggest you go the WMS route or some kind of image server.  To get the performance out of WMS I suggest that you use the FileBitmapTile cache and cache as much of the data as images as you can.  You can pre-generate some of it but you can also cache it as you draw it.  Then on the client side I would use another FileBitmapTileCache to cache locally also.  There are so many things to consider like if the user can turn layers on and off, how often the layers expire, how often does the data need to change.  I am afraid there is not a one size fits all answer to this.  The more information you give us the better to help.   
  
 A few things though.  If the data is in shape files now I would leave them in there.  They are optimized to draw fast and while SQL is nice and flexible if you don’t need the flexibility then shape files are your best bets.  I would steer clear of rendering form SQL over the wire on the client.  This is going to be fairly slow and load down you SQL server. 
  
 I would also point you to professional services as a few hours consulting time could bring us up to speed on your requirements and we can point you in the right direction with the API to use etc.  At this critical juncture where you are defining your infrastructure it is important to get it right as it has a huge impact over the life of your project. 
  
   Let me also see what I can do for a WMS solution, I know that we have a sample that ships with the Services Edition on a very simple WMS kind of thing.  I also think there is a project for a commercial WMS server but I haven’t worked with that team so I will need to find out more. 
  
 David

Hello David, 
  
 thanks for information. 
  
 I found additional information on the following thread gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/11/aft/6195/afv/topic/Default.aspx
  
 I look forward on your information about commercial WMS-Server.  I see it is not as easy as i thought to point out the architecture. You are right there are many things to consider. 
  
 I would collect more information and provide it to you. But some data may be imprecise because the data they are displayed in our mapping application were defined by the users so I can only estimate parameters e.g. size of data. 
  
 Thomas 
  


Thomas, 
  
   I have written allot about this topic over time.  That is why we have been working on an out of the box server solution.  The server solution can handle half of the problem while half is still on the developers.  We can handle the server and client side caching of the images in the server and special client but the developer still need to consider how to partition the data to get the rendering time really fast. 
  
   I will send the details on the server early next week.  Please respond back to this post to keep it on our hot list. 
  
 David

Hello David, 
  
 I would provide you with additional information. Can you send me an e-mail address? 
  
 Thomas

Thomas, 
  
 email support@thinkgeo.com and ask them to forward the mail to David. 
  
 David

Hello David, 
  
 I’m still waiting for your information on WMS server and my questions in the document I send to you! 
  
 Thomas

Thomas, 
  
   I just talked with the support folks and they don’t have a record of getting an e-mail from you.  If you can re-sent it to support@thinkgeo.com and ask for confirmation of receipt.  Also let me know on the forum after you send it and I can have them check their junk mail etc.  Sorry but I let you sending the e-mail drive my response back and since I didn’t get it I didn’t move forward on this.  I look forward to seeing your document and answering any questions you may have. 
  
 David

Hello David, 
  
 enclosed you will get information on our requirements and use cases. 
  
 Infrastructure: 
 - Windows Forms Client/Server Application with about 50-100 Client PC 
 - .Net Framework 2.0 
 - Database Server - MS SQL-Server 2005 (sometimes Oracle) 
 - Client communicates with Application-Server via Web Service. Application-Server translates client request and communicates with Database Server. 
  
 Requirements: 
 - Data to display on the map can come from following sources.  
   Shapefiles  - Roads,Street,Buildings 
    Rasterfiles (e.g. Geo Tiff) – satellite pictures, street/city map 
   Dataset (SQL-Query on Geo-Data in Database / Shape stored as WKB) 
   WMS ( Internet ) 
 The file based data e.g. shapefile or Geo-Tiff should mainly be stored on Application Server. Shapefile and rasterfile will be updated over a period of 1 year or greater. 
  
 - The user can create his own layers by defining where the data come from (raster, shape, dataset……) and what kind of style is used if kind of layer is shapefile or dataset. Also he can define thematic maps on using ValueStyles or ClassBreakStyles. 
  
 - Also the user can define groups of layers so he can display or hide them at once by switching the layer group on/off. 
  
 - Data shown on the map they come from shapefile or dataset can be selected by clicking on the map or dragging a rectangle where all features within should be selected.  
  
 - The user can inspect the column data of selected feature 
  
 - The user can drag and edit or create new shapes if layer is a dataset layer.  
 ----------------------------------------------------------------------------------------------------------------------------- 
  
 Question: 
 David what I have understood is that we can speed up our application if the user groups his defined layers  together and render them on Application server by WMS or some kind of image server. I think this is one part of the design. 
  
 But if the user creates a shapefile layer or dataset layer where shapes have to be selected or edited within the map. What is the better solution? 
  
 a.) 
 Provide the data they are in shapefile or dataset  as WMS image. Then, if user tries to select some elements in the map I Query the Application-Server to get all features within the selection and move them to highlight- or edit-layer. 
  
 OR 
  
 b.) 
 If layer is a dataset layer. I query the data from database server and use my own layer and feature source based on your “ExtendingMapSuiteFeatureSource_VB”-demo. So I can select and edit the features without connecting the application server again. However I have to paint the layer on the client. 
 I don’t know if this is slow. Also I don’t understand how to proceed with shapefiles if I don’t want to load it to the client. 
 Any ideas? 
  
 Also I’m still waiting on your information about commercial WMS-Server! 
  
 Thanks Thomas

Thomas, 
  
 By adding the WMS server you get a few things.  You get the ability to pre-render and tile data so that users can share tiles between the 50 PCs.  You get the advantage of not having to distribute the data to all of the PCs as well. 
  
 To your questions… 
  
 The answer depends on the data layers themselves. 
  
 Answer A is good when: 
  
 1. The features change infrequently 
 2. Few users will change them 
 3. the features are large and complex 
 4. The features render slowly in real-time 
  
 The reasoning above is that if the shapes are complex and big and render slowly then you don’t want to always pull them to the client.  if they don’t change very often then cached tiles till offer you better performance. If you do not satisfy these requirements then the problems you face is that if many people edit it then you need to be able to invalidate the cache very often which may cause the cache to be ineffective and put more load on the server. 
  
 Answer B is good when: 
  
 1. Features change very often 
 2. Many users can change them 
 3. The data is relatively small or sparse 
 4. The features can be rendered quickly 
  
 In this case you know the data changes often and it is better to bring the data to the client and render it so you have full control.  You don’t have to mess with caches etc and as long as the data is not huge it should be pretty fast.  Since you query it on the fly many users changing things is ok because the data is never cached and never becomes stale.  I think that with the video and also all of the different feature source we offer you should be able to get something rolling quickly. 
  
 The other part of the WMS type of server is a WFS server which communicated the data as XML and is a feature server, it has an editing API to it as well to communicate changes to the back end.  We do support reading from a WFS server but we do not yet offer a WFS server.  The downside is that WFS being XML is bloated and can be slow for large amounts of data.  When we build out our server system we will have a fast binary option but that is some time away.  What we are seeing now is that people are moving the next step from just controls and data locally to larger cached solutions on centralized clients and we are making progress to get solution in that area. 
  
 Sorry ont he WMS stuff, many of the resource have been busy with the impending next wave of releases next week and then full releases of the Silverlight, Desktop, Routing etc very soon afterwords.  Maybe the best thing to do is setup a call so I can discuss what exactly we have with you.  If you are up for that e-mail support with your number and ask them to send it to David and also followup with me to let me know you sent it. 
  
 Let me know if this helps and keep asking questions! 
  
 David 


Thomas, 
  
   I left something out.  The way you would work with a shape file remotly is to create a new feature source and layer.  In this one it would send a request to a web page, WCF server, soap server or something.  That listener would load the shape file using our feature source and you would pass over the request the bounding box and on the server you get all the features and change them into binary or text and send them back to the client.  You could also so something similar with the updates.  I will whip up a small sample class with some comments to give you an idea.  More to come in a few minutes. 
  
 David

Thomas,


Here is a little sample to show you how to build the client side part.  The server side part is pretty easy and you just need to choose the communication method, custom web request, WCF, Soap, Custom TCP/IP etc.  Inside the server side just use the feature source's that come with Map Suite. 


Here is the client side:


    

    public class RemoteFeatureSource : FeatureSource
    {
        // You will need some kind of constructor so that you can tell the remote side what file to access etc.
        // you may also want to pass in what the connection parameters are to the server
        public RemoteFeatureSource(Uri serverUri, string remoteDataInformation)
        {
            // In here you just cache the connection iformation etc so it can be used later on
        }

        protected override Collection<Feature> GetFeaturesInsideBoundingBoxCore(RectangleShape boundingBox, System.Collections.Generic.IEnumerable<string> returningColumnNames)
        {
            // Here you will make a call to the server passing the table you want to find the stuff in
            // you would return features and pass them back in a collection
        }

        // At this point we don't want to deal with SQL.  If you wanted you can everride all of the SQL 
        // methods and them pass the SQL calls to the server side and then ferry the results back to the client
        protected override bool CanExecuteSqlQueryCore
        {
            get
            {
                return false;
            }
        }

        protected override Collection<Feature> GetAllFeaturesCore(System.Collections.Generic.IEnumerable<string> returningColumnNames)
        {
            // Here you will call the server and get all the features.  This is a backup and may not need to be
            // added if you override the GetFeaturesInBoundingBox.  I would add code here and thow an exception
            // if you get into here becasue soemthing went wrong
        }

        protected override TransactionResult CommitTransactionCore(TransactionBuffer transactions)
        {
            // This is going to fire whenever the user commits.  You can then call a server side API 
            // to update the file on the server side.
        }


        // The three items below which are the columns, count and bounding box I would populate in one step
        // When you call any one of them I would make a special call to the server to get all three pieces of
        // information and cache it locally.  In this way you limit the overhead in going back to the server.
        //  Note that if you add, or remove data you may need to refresh these with another trip to the server
        protected override Collection<FeatureSourceColumn> GetColumnsCore()
        {
            // If you do not have them cached already then go to the server and get the columsn, count and bousning box then cache it.
        }

        protected override int GetCountCore()
        {
            // If you do not have them cached already then go to the server and get the columsn, count and bousning box then cache it.
        }

        protected override RectangleShape GetBoundingBoxCore()
        {
            // If you do not have them cached already then go to the server and get the columsn, count and bousning box then cache it.
        }
    }

    public class RemoteFeatureLayer : FeatureLayer
    {
        public RemoteFeatureLayer(Uri serverUri, string remoteDataInformation)
        {
            this.FeatureSource = new RemoteFeatureSource(serverUri, remoteDataInformation);
        }

        // Set this to true if your data set can easily and quickly return a bounding box
        // It can save allot of time of it is handy for you to get
        public override bool HasBoundingBox
        {
            get
            {
                return true;
            }
        }
    }

    
 

David



Hello David, 
  
 Thanks for all the help. I will continue with development and post questions to the forum if needed. 
  


Thanks David for your help.  
  
 Thomas Thanks for letting us know your status. 
  
 Just feel free to let me know if any more questions. 
  
 Yale