Is there any way to load shapefiles from database?

10 posts, 0 answers
  1. Thomas
    Thomas avatar
    8 posts
    Member since:
    Oct 2008

    Posted 10 Jun 2011 Link to this post

    Hi Team,

    My shapefiles is user-defined and store in database,but the ShapeFileReader load shapefiles from resource.The shapefiles must be embed in the project assembly.

    I want to find a way to load shapefiles from database.

    Could you help me?

    btw
    I have retreived  shapefiles from my database to my silverlight application in chunks of binary.

    Now I am able to combine all the binary chunks into a byte array to get the actual size of the shapefiles stored in my Database.

    Can anyone tell how to bind these bytes directly into a RadMap?


  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 15 Jun 2011 Link to this post

    Hi Thomas,

    If you have the shape file as a byte array, then I would recommend to use the ShapeFileReader.Read method which allows to read a shape file from a stream.
    The sample code is below.
    private void ReadShapes(byte[] bytes)
    {
        using (MemoryStream stream = new MemoryStream(bytes))
        {
            List<FrameworkElement> list = ShapeFileReader.Read(stream);
            foreach (FrameworkElement item in list)
            {
                this.informationLayer.Items.Add(item);
            }
        }
    }

    Kind regards,
    Andrey Murzov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Thomas
    Thomas avatar
    8 posts
    Member since:
    Oct 2008

    Posted 29 Jun 2011 Link to this post

    It's work,Thank a lot.
  5. Rasid
    Rasid avatar
    5 posts
    Member since:
    Oct 2011

    Posted 08 Apr 2012 Link to this post

    can i have some project sample for me to understand the whole concept? I'm still can't get the idea how to load from database. I've the project with load the .shp file directly from the folder and it's fine if it running locally, but whenever i'm publish at the server, the shapefile never loaded. So, i'm thinking just using this method i.e. load from database which it will be flexible as user may update the source data in database.
  6. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 12 Apr 2012 Link to this post

    Hello Rasid,

    I think it is not too good idea to have shape-file "as is" in the database. When you use a folder of Web server for shape files then most often this problem occurs in published projects when MIME types for shp and dbf files are not defined on the web server.
    Please check that MIME types for using shape files are defined:
    Extensions: .shp and .dbf
    MIME type: application/octet-stream

    Also you can check if an error occurs during loading of shape files. You can use the PreviewReadCompleted or ReadCompleted event to check the eventArgs.Error property. It returns the exception when the error occurs.

    Greetings,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  7. Josh
    Josh avatar
    8 posts
    Member since:
    Nov 2012

    Posted 17 Jan 2013 Link to this post

    How did you store the shapefiles in the database?  Just .shp or did you store .shp, .shx and .dbf?
  8. Thomas
    Thomas avatar
    8 posts
    Member since:
    Oct 2008

    Posted 17 Jan 2013 Link to this post

    All of .shp, .shx and .dbf,and handle load order .

  9. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 18 Jan 2013 Link to this post

    Hello,

    RadMap don't use .shx files and it have no interface to load them. The .dbf file is optional. If you need to accompany map shapes with additional information then you can use .dbf file.

    Regards,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  10. Jon_BCV
    Jon_BCV avatar
    16 posts
    Member since:
    Mar 2012

    Posted 25 Apr 2013 Link to this post

    How do you load the dbf file too?  Along with the shape file?
  11. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 26 Apr 2013 Link to this post

    Hello Jon,

    Please, take a look into the following topic in our online documentation:

    http://www.telerik.com/help/silverlight/radmap-features-shapefiles-support.html

    It describes how the DBF file can be loaded along with the SHP file.

    Kind regards,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner