Quantcast
Channel: DotSpatial
Viewing all 3973 articles
Browse latest View live

New Post: Looping over layers in map

$
0
0
Hi, I'm trying to loop over layers in the map and populate them into a combo box. The user will select one of the layers from the combo box to perform an operation on. How does one loop over layers in the map and get their details?

New Post: Looping over layers in map

$
0
0
get a map layer collection
Dim lyrs As IMapLayerCollection = map.Layers
or if you want only from a certain map group
Dim lyrs As IMapLayerCollection = mapgrp.Layers
then iterate through the collection and parse out each layer. note that if you have groups then you may have to iterate further
                    For Each lyr As ILayer In lyrs
                        If TypeOf lyr Is IMapLineLayer Then
                            Dim lineLyr As MapLineLayer = CType(lyr, MapLineLayer)
                            Debug.Print(lineLyr.LegendText)
                        End If
                    Next lyr

Reviewed: DotSpatial 1.9 (Nov 29, 2016)

$
0
0
Rated 4 Stars (out of 5) - DotSpatail 1.9 missing any Layout control. How to solve this problem?

Closed Unassigned: FeatureSet.Open(".shp") throws wrong error if .shx is missing [63637]

$
0
0
If the .shx file is missing from the same path the exception thrown indicates the .shp fileName is missing but should instead indicate that the .shx fileName is missing.
Comments: fixed in 2.0 on github

Closed Unassigned: I have attached references but they are not Enabled.? [63639]

$
0
0
i heve attached dotspital controler.dll
Comments: If you still have this problem please explain it in more detail on https://github.com/DotSpatial/DotSpatial/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc

Closed Unassigned: Incorrect selection of polygons with Holes [63638]

$
0
0
Found a bug in the PartRange class under the method of IsHole.

This:

if (i < EndIndex)
{
x2 = Vertices[(i + 1) * 2];
y2 = Vertices[(i + 1) * 2 + 1];
}
else
{
x2 = Vertices[StartIndex];
y2 = Vertices[StartIndex + 1];
}

should be changed to:

if (i < EndIndex) {
x2 = Vertices((i + 1) * 2);
y2 = Vertices((i + 1) * 2 + 1);
} else {
x2 = Vertices(StartIndex * 2);
y2 = Vertices(StartIndex * 2 + 1);
}

I have attached a shapefile ("ModArea", not the Union) to show you the problem. Try clicking on the bottom left shape and you will notice that both shapes get selected even though the outside shape is a donut.
Comments: Fixed on github https://github.com/DotSpatial/DotSpatial/issues/905

Closed Issue: Is this a bug in DotSpatial.WebControls? [22810]

$
0
0
Hello,
I have a shp file which is exported by dxf file. I add the shp file to GDIMap and run the WebDemo,These is no map show in the WebMap control. I click the ZoomIn buttom,then throw the System.OverflowException.

The error in GDIMapFrame.cs
public Point ProjToPixel( Coordinate location){...}
params: location.x=NaN,location.y=NaN
 
 
I modify the code in GDIMap.cs like this:
public IMapLayer AddLayer(string fileName)
{
IDataSet dataSet = DataManager.DefaultDataManager.OpenFile(fileName);
 
//if (dataSet.Projection != Projection)
//{
//dataSet.Reproject(Projection);
//}
if (!dataSet.Projection.Equals(Projection)) {
dataSet.Reproject(Projection);
}
 
 
return Layers.Add(dataSet);
}
 
Now shp file is show in webmap control. Is this a bug?
Comments: https://github.com/DotSpatial/DotSpatial/issues/496

Closed Unassigned: LegendText ReadOnly [63599]

$
0
0
Hi,
I'm using this code for to identify the single layer present in 'MapLayers'

```
IMapFeatureLayer[] arrayLayer = currentMap.GetFeatureLayers();

foreach (IMapFeatureLayer layer in arrayLayer)
{
if (layer.LegendText.Equals(layerToRemoved.LegendText))
{
//TODO
}
}

```

In treeview of 'MapLayers', can I block the name of layer as ReadOnly?

Thanks.
Comments: https://github.com/DotSpatial/DotSpatial/issues/750

New Post: Nmea Emulator Protocol

$
0
0
Nmea Emulator in DotSpatial.Positioning. can emulate gps tracking device. Real tracking gps devices have protocols which they use when sending data. So my question is there any protocol for Nmea Emulator in DotSpatial.Positioning.

I am testing traccar server on localhost and I want to use Nmea Emulator in DotSpatial.Positioning to send data to the server. The traccar server needs the protocol of the gps tracking device if it is to start listening to it.

I am new to GPS device programming.Help !

New Post: Reprojection Inaccuracy from 20355 to 4326

$
0
0
I am trying to reproject some points in EPSG:20355 to EPSG:4326 and cannot seem to get an accurate result.

Here is an example:

Point in EPSG:20355: 665423.2146,7458565.1391

If I reproject this point using the http://epsg.io/ website I get the following result

148.6147785 -22.9713145

If i reproject the point using ProjNet I get the same result

However when i reproject the point using DotSpatial I get a different result
148.613698385575 -22.9728720945436

Here is my sample code:

var sourceProjection = ProjectionInfo.FromAuthorityCode("EPSG", 20355);
var targetProjection = ProjectionInfo.FromAuthorityCode("EPSG", 4326);

double[] fromPoint = new double[] { 665423.2146, 7458565.1391 };

Reproject.ReprojectPoints(fromPoint, null, sourceProjection, targetProjection, 0, 1);

I have tried creating my source and target projections from Esri strings and Proj4 strings and always seem to end up with the same result.

Any guidance as to how I can get an accurate result would be much appreciated!

New Post: Missing wiki page: DotSpatial.Analysis

$
0
0

New Post: Reprojection Inaccuracy from 20355 to 4326

$
0
0
Try the latest build. I think they did some updates on the re-projection calculations.
~AGP

New Post: Creating a Shape File

$
0
0
I am not sure why it wont save it in the first place. But when I try to save a Shape File, it errors, I get the following error. I cant figure out what I am missing.

Here is the Code:
Dim returnval As DotSpatial.Data.FeatureSet = New FeatureSet(ShapeType)
        returnval.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984
returnval.DataTable.Columns.Add(New DataColumn("MyTest", GetType(System.String)))
returnval.SaveAs(String.Format("{0} ", "C\MyFolder\TestShapeFile.shp"), True)



'he specified file type is not supported. at DotSpatial.Data.DataManager.CreateVector(String fileName, FeatureType featureType, IProgressHandler progHandler) in g:\TeamCity\buildAgent\work\8dcaae3a01f0640d\Trunk\DotSpatial.Data\DataManager.cs:line 166
at DotSpatial.Data.FeatureSet.SaveAs(String fileName, Boolean overwrite) in g:\TeamCity\buildAgent\work\8dcaae3a01f0640d\Trunk\DotSpatial.Data\FeatureSet.cs:line 909 at RevCoreService.RevCoreService.CreateShapeFile(FeatureType ShapeType, ObservableCollection`1 columns, String ShapeFileName) in C:\Visual Studio 13\Projects\RevCoreService\RevCoreService\RevCoreService.vb:line 131



First question is Why does it not save?

Second is : What is with "g:\TeamCity\buildAgent\work\8dcaae3a01f0640d\Trunk\DotSpatial.Data\DataManager.cs:line 166"

New Post: Creating a Shape File

$
0
0
Your path should begin with C:\ not C\ . If you're missing the : in your code too, you might get the wrong error message because DS can't recognize it as path.

New Post: Creating a Shape File


New Post: M Values for points or lines

$
0
0
I am really stuck. I have been able to create a point Shape File With X, Y, and Z Values I cannot get it to keep the M Values I am setting. Afetr creating the Shape File, I open it inside of ArcMap. It says it has Z and M but neither show up when editing. it return "NaN" for the M Value

I get the same for a multiline Shape, (I think this is how you make a polyline) except it also return a "NaN" for the Z value even though I set it.

I use the same set of coordinate points to create the line as well as the Point shape files.

New Post: M Values for points or lines

$
0
0
What version of DotSpatial do you use?

Please post the code you used to create, fill and save the shapefile.

New Post: M Values for points or lines

$
0
0
I am using the latest 1.9

Here is the code

Private Function CreateShapeFile(ShapeType As FeatureType, columns As ObservableCollection(Of PointColumns), ShapeFileName As String) As FeatureSet
    Try

        Dim returnval As DotSpatial.Data.FeatureSet = New FeatureSet(ShapeType)

        returnval.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984
        returnval.CoordinateType = CoordinateType.Z


        For i = 0 To columns.Count - 1
            Dim column As DataColumn = New DataColumn(columns(i).ColumnName)
            Select Case columns(i).ColumnType
                Case Is = "String"
                    returnval.DataTable.Columns.Add(New DataColumn(columns(i).ColumnName, GetType(System.String)))
                Case Is = "Date"
                    returnval.DataTable.Columns.Add(New DataColumn(columns(i).ColumnName, GetType(System.DateTime)))
                Case Is = "Double"
                    returnval.DataTable.Columns.Add(New DataColumn(columns(i).ColumnName, GetType(System.Double)))
            End Select
        Next
        returnval.SaveAs(String.Format("{0}", ShapeFileName), True)
        Return returnval
    Catch ex As Exception
        WriteToFile(ex.Message & ex.StackTrace)
        Return Nothing
    End Try

End Function


Private Function AddPointFeatureToShape(coords As List(Of Coordinate), columns As ObservableCollection(Of PointColumns), Optional lineF As FeatureSet = Nothing) As DotSpatial.Data.FeatureSet
    Dim pointF As New FeatureSet(FeatureType.Point)
    Try




        pointF.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984
        pointF.CoordinateType = CoordinateType.Z

        For i = 0 To columns.Count - 1
            Dim column As DataColumn = New DataColumn(columns(i).ColumnName)
            Select Case columns(i).ColumnType
                Case Is = "String"
                    pointF.DataTable.Columns.Add(New DataColumn(columns(i).ColumnName, GetType(System.String)))
                Case Is = "Date"
                    pointF.DataTable.Columns.Add(New DataColumn(columns(i).ColumnName, GetType(System.DateTime)))
                Case Is = "Double"
                    pointF.DataTable.Columns.Add(New DataColumn(columns(i).ColumnName, GetType(System.Double)))
            End Select
        Next

    Catch
    End Try



    Try
        For i = 0 To coords.Count - 1
            Dim coord As Coordinate = New Coordinate(coords(i).X, coords(i).Y, coords(i).Z)
            Dim newpoint As DotSpatial.Topology.Point = New DotSpatial.Topology.Point(coord.X, coord.Y, coord.Z)
            Dim currentFeature As DotSpatial.Data.IFeature = pointF.AddFeature(newpoint)
            currentFeature.DataRow("Owner") = "THE OWNER " & i.ToString
            currentFeature.DataRow("OwnedSince") = Now.ToShortDateString
        Next




        Return pointF

    Catch ex As Exception
        WriteToFile(ex.Message & ex.StackTrace)
        Return Nothing
    End Try

End Function
When using the addpointoshape Fuinction and saving the returned featureset as the ShapeFile I get the NaN result.

New Post: M Values for points or lines

$
0
0
The only reason I see for your M beeing NaN is that you didn't add it to your features. So change
Dim newpoint As DotSpatial.Topology.Point = New DotSpatial.Topology.Point(coord.X, coord.Y, coord.Z)
to
Dim newpoint As DotSpatial.Topology.Point = New DotSpatial.Topology.Point(coords(i).X, coords(i).Y, coords(i).Z, coords(i).M)
to include M. If you didn't remove something from your function creating coord is not nessessary.

The following code creates a shapefile that contains M and Z values.
  Private Function AddPointFeatureToShape() As FeatureSet
        Dim pointF As New FeatureSet(FeatureType.Point)
        Try

            Dim coords As New List(Of Coordinate)
            coords.Add(New Coordinate(1, 2, 3, 4))
            coords.Add(New Coordinate(4, 5, 6, 7))
            coords.Add(New Coordinate(7, 8, 9, 10))


            pointF.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984
            pointF.CoordinateType = CoordinateType.Z

            For i = 0 To coords.Count - 1
                Dim newpoint As DotSpatial.Topology.Point = New DotSpatial.Topology.Point(coords(i))
                Dim currentFeature As IFeature = pointF.AddFeature(newpoint)
            Next


            pointF.SaveAs("D:\test.shp", True)

            Return pointF

        Catch ex As Exception
            MsgBox(ex.Message & ex.StackTrace)
            Return Nothing
        End Try

    End Function

New Post: M Values for points or lines

$
0
0
Yea I dont know how I missed that. If you could also advise me, I am trying to produce the same thing with a LineString Feature.

I basically am getting the same result. The Features are there, They show that they support Z and M, but during editing in ArcMap, those values are NaN.

I used the same approach from the Function you showed. Being constructed a little differntly, I also followed the "DotSpatial_4_Attributes Table.docx" document and modified it to what I though was correct.

Private Function AddPolyLineFeatureToShape(coords As List(Of Coordinate), columns As ObservableCollection(Of PointColumns)) As FeatureSet
   dim lineF As FeatureSet = New FeatureSet(FeatureType.Line)

    Try

        lineF.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984
        lineF.CoordinateType = CoordinateType.Z

        For i = 0 To columns.Count - 1

            Dim column As DataColumn = New DataColumn(columns(i).ColumnName)
            Select Case columns(i).ColumnType

                Case Is = "String"
                    lineF.DataTable.Columns.Add(New DataColumn(columns(i).ColumnName, GetType(System.String)))

                Case Is = "Date"
                    lineF.DataTable.Columns.Add(New DataColumn(columns(i).ColumnName, GetType(System.DateTime)))

                Case Is = "Double"
                    lineF.DataTable.Columns.Add(New DataColumn(columns(i).ColumnName, GetType(System.Double)))

            End Select

        Next


    Dim lineArray As New List(Of Coordinate)
    Dim lineGeometry As LineString = New LineString(lineArray)
    Dim lineFeature As DotSpatial.Data.IFeature = lineF.AddFeature(lineGeometry)
    lineFeature.Coordinates.Add(New Coordinate(coords(0).X, coords(0).Y, coords(0).Z, coords(0).M))
    lineFeature.DataRow("Owner") = "THE OWNER"
    lineFeature.DataRow("OwnedSince") = Now.ToShortDateString
    Dim existingFeature As DotSpatial.Data.IFeature = lineF.Features(lineF.Features.Count - 1)

    For i = 0 To coords.Count - 1
     existingFeature.Coordinates.Add(New Coordinate(coords(i).X, coords(i).Y, coords(i).Z, coords(i).M))
    Next
    If (existingFeature.Coordinates.Count >= 2) Then
      lineF.InitializeVertices()
    End If


    lineF.SaveAs("D:\test.shp", True)
    Return lineF

    Catch ex As Exception
        MsgBox(ex.Message & ex.StackTrace)
        Return Nothing
    End Try

End Function
Viewing all 3973 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>