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

New Post: Find all Polygons a Linestring intersects

$
0
0
You should go with NetTopologySuite's PreparedGeometry functionality. There is a conversion project between DotSpatial geometries/shapes and GeoAPI/NTS geometries if you rely on other DotSpatial functionality.

the code would then look somewhat like this:
//get line strings from somewhere
var dsLineStrings = new List<DotSpatial.Topology.ILineString>();
// get polygons from somewhere else
var dsPolygons = new Dictionary<DotSpatial.Topology.IPolygon, int>();

// build a quadtree index on the polygons
var dsQuadTree = new DotSpatial.Topology.Index.Quadtree.Quadtree();
var i = 0;
foreach (var dsPolygon in dsPolygons.Keys)
{
    dsQuadTree.Insert(dsPolygon.EnvelopeInternal, i++);
}

// iterate over all line strings
foreach (var dsLineString in dsLineStrings)
{
    // convert to GeoAPI linestring
        var lineString = dsLineString.ToGeoAPI();
        // build a prepared geometry, which is optimized for a one against many comparison
    var prepLineString = NetTopologySuite.Geometries.Prepared.PreparedGeometryFactory.Prepare(lineString);
        // search quad tree for polygon candidates
    foreach (var kvp in dsQuadTree.Query(dsLineString.EnvelopeInternal))
    {
                // Do intersection test and increment counter
        if (prepLineString.Intersects(kvp.Key))
        {
                        // Does this really work, I have not tried.
            dsPolygons[kvp.Key]++;
        }
    }
}

Commented Unassigned: Label spatialite layer [24339]

$
0
0
The code for adding new layer from SQL Spatialite database in DotSpatial map works OK:

SpatiaLiteHelper slh = new SpatiaLiteHelper();
GeometryColumnInfo item = r.DataBoundItem as GeometryColumnInfo;
IFeatureSet fs = slh.ReadFeatureSet(connString, item);
IMapFeatureLayer lay = mainMap.Layers.Add(fs);

But labelling this "spatialite" layer allways fails when use "Label Setup" from legend and fails also "Export Data All features" too (shape file from this action is corrupted).


Thanks for considering my request, Vojko
Comments: Associated with changeset 73587: Fixed #24339: Label spatialite layer

Edited Issue: Label spatialite layer [24339]

$
0
0
The code for adding new layer from SQL Spatialite database in DotSpatial map works OK:

SpatiaLiteHelper slh = new SpatiaLiteHelper();
GeometryColumnInfo item = r.DataBoundItem as GeometryColumnInfo;
IFeatureSet fs = slh.ReadFeatureSet(connString, item);
IMapFeatureLayer lay = mainMap.Layers.Add(fs);

But labelling this "spatialite" layer allways fails when use "Label Setup" from legend and fails also "Export Data All features" too (shape file from this action is corrupted).


Thanks for considering my request, Vojko
Comments: ** Comment from web user: mogikanin **

Thanks for posting the patch. I've applied it to trunk.

Updated Wiki: OpeningCS

$
0
0

This code demonstrates how to open an existing shapefile as a new feature set using the System.Spatial.Desktop library.

using DotSpatial.Data;

  publicvoid OpeningFS()
        {
           //Pass in the file path for the standard shapefile that will be opened
           IFeatureSet fs = FeatureSet.Open("C:\\Temp\\roads.shp");  
        }

Updated Wiki: OpeningCS

$
0
0

This code demonstrates how to open an existing shapefile as a new feature set using the DotSpatial.Data library.

using DotSpatial.Data;

  publicvoid OpeningFS()
        {
           //Pass in the file path for the standard shapefile that will be opened
           IFeatureSet fs = FeatureSet.Open("C:\\Temp\\roads.shp");  
        }

Updated Wiki: OpeningVB

$
0
0

This code demonstrates how to open an existing shapefile as a new feature set using the DotSpatial.Data library.

Imports System.Windows.Forms
Imports DotSpatial.Data

PrivateSub button1_Click(sender AsObject, e As EventArgs)
	' Pass in the file path for the standard shapefile that will be openedDim fs As IFeatureSet = FeatureSet.Open("C:\\Temp\\roads.shp")
EndSub

Edited Issue: Documentation on open an existing shapefile [23686]

$
0
0
The code here doesn't work: http://dotspatial.codeplex.com/wikipage?title=OpeningCS&referringTitle=Desktop_SampleCode
Comments: ** Comment from web user: mogikanin **

Documentation updated.

Edited Issue: Bad Display of NetCDF File [22370]

$
0
0
Using DemoMap.exe with GDAL Extension.
The attached .nc file is flipped (south USA is displayed in the north)

Edited Issue: Bad Display of NetCDF File [22370]

$
0
0
Using DemoMap.exe with GDAL Extension.
The attached .nc file is flipped (south USA is displayed in the north)

Commented Unassigned: latest NuGet package missing key element [24496]

$
0
0
I downloaded the latest version (version 1.5.1) of dotSpatial assemby with NuGet, the map and legend controls are missing the dotSpatial.Controls.dll.

Lee
Comments: ** Comment from web user: mogikanin **

They not missed. See explanation at https://dotspatial.codeplex.com/workitem/24217

Closed Unassigned: latest NuGet package missing key element [24496]

$
0
0
I downloaded the latest version (version 1.5.1) of dotSpatial assemby with NuGet, the map and legend controls are missing the dotSpatial.Controls.dll.

Lee

Commented Issue: ArgumentOutOfRange exception in LineShapeFile.cs [22528]

$
0
0
A counter in LineShapeFile.cs can get out of sync with what it is iterating over if there are any ShapeType.NullShape objects in the shp file. See the bottom of this bug report for what the I think the problem and solution is.
 
File that causes the exception can be found here: http://ocs-gis.ncd.noaa.gov/cm_vs/Merged_Vector_Shoreline.zip
 
Download this zip file, extract contents, then pass the path of the extracted .shp file to DataManager.DefaultDataManager.OpenFile(path) - it will throw the following exception:
 
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at DotSpatial.Data.LineShapefile.FillLines(String fileName, IProgressHandler progressHandler) in C:\src\DotSpatial\DotSpatial.Data\LineShapefile.cs:line 299
at DotSpatial.Data.LineShapefile.Open(String fileName, IProgressHandler progressHandler) in C:\src\DotSpatial\DotSpatial.Data\LineShapefile.cs:line 88
at DotSpatial.Data.Shapefile.OpenFile(String fileName, IProgressHandler progressHandler) in C:\src\DotSpatial\DotSpatial.Data\Shapefile.cs:line 328
at DotSpatial.Data.Shapefile.OpenFile(String fileName) in C:\src\DotSpatial\DotSpatial.Data\Shapefile.cs:line 269
at DotSpatial.Data.ShapefileDataProvider.Open(String fileName) in C:\src\DotSpatial\DotSpatial.Data\ShapefileDataProvider.cs:line 119
at DotSpatial.Data.ShapefileDataProvider.DotSpatial.Data.IDataProvider.Open(String fileName) in C:\src\DotSpatial\DotSpatial.Data\ShapefileDataProvider.cs:line 65
at DotSpatial.Data.DataManager.OpenFile(String fileName, Boolean inRam, IProgressHandler progressHandler) in C:\src\DotSpatial\DotSpatial.Data\DataManager.cs:line 375
at DotSpatial.Data.DataManager.OpenFile(String fileName) in C:\src\DotSpatial\DotSpatial.Data\DataManager.cs:line 312
at Entiat.Cartography.ShapefileMap.InitializeFromPath(String path) in C:\src\entiat\Entiat\Cartography\ShapefileMap.cs:line 78
 
Specific lines of code that lead to the error:
 
200:
int numShapes = shapeHeaders.Count;
 
236: [[[causes ShapeIndices to no longer have a Count of numShapes]]]
 
if (shape.ShapeType == ShapeType.NullShape)
{
continue;
}
 
288:
ShapeIndices.Add(shape);
 
293:
List<ShapeRange> shapes = ShapeIndices;
 
297:
for (int shp = 0; shp < numShapes; shp++)
{
ShapeRange shape = shapes[shp];
BOOM.
 
Fix (I think): line 297 should read:
for (int shp = 0 ; shp < shapes.Count ; shp++)
 
But I'm not a shapefile expert. It is worth taking a hard look at whether the code in the offending for loop also needs to execute for NullShape...(?)
Comments: ** Comment from web user: mogikanin **

Duplicate of https://dotspatial.codeplex.com/workitem/23945

Closed Issue: ArgumentOutOfRange exception in LineShapeFile.cs [22528]

$
0
0
A counter in LineShapeFile.cs can get out of sync with what it is iterating over if there are any ShapeType.NullShape objects in the shp file. See the bottom of this bug report for what the I think the problem and solution is.
 
File that causes the exception can be found here: http://ocs-gis.ncd.noaa.gov/cm_vs/Merged_Vector_Shoreline.zip
 
Download this zip file, extract contents, then pass the path of the extracted .shp file to DataManager.DefaultDataManager.OpenFile(path) - it will throw the following exception:
 
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at DotSpatial.Data.LineShapefile.FillLines(String fileName, IProgressHandler progressHandler) in C:\src\DotSpatial\DotSpatial.Data\LineShapefile.cs:line 299
at DotSpatial.Data.LineShapefile.Open(String fileName, IProgressHandler progressHandler) in C:\src\DotSpatial\DotSpatial.Data\LineShapefile.cs:line 88
at DotSpatial.Data.Shapefile.OpenFile(String fileName, IProgressHandler progressHandler) in C:\src\DotSpatial\DotSpatial.Data\Shapefile.cs:line 328
at DotSpatial.Data.Shapefile.OpenFile(String fileName) in C:\src\DotSpatial\DotSpatial.Data\Shapefile.cs:line 269
at DotSpatial.Data.ShapefileDataProvider.Open(String fileName) in C:\src\DotSpatial\DotSpatial.Data\ShapefileDataProvider.cs:line 119
at DotSpatial.Data.ShapefileDataProvider.DotSpatial.Data.IDataProvider.Open(String fileName) in C:\src\DotSpatial\DotSpatial.Data\ShapefileDataProvider.cs:line 65
at DotSpatial.Data.DataManager.OpenFile(String fileName, Boolean inRam, IProgressHandler progressHandler) in C:\src\DotSpatial\DotSpatial.Data\DataManager.cs:line 375
at DotSpatial.Data.DataManager.OpenFile(String fileName) in C:\src\DotSpatial\DotSpatial.Data\DataManager.cs:line 312
at Entiat.Cartography.ShapefileMap.InitializeFromPath(String path) in C:\src\entiat\Entiat\Cartography\ShapefileMap.cs:line 78
 
Specific lines of code that lead to the error:
 
200:
int numShapes = shapeHeaders.Count;
 
236: [[[causes ShapeIndices to no longer have a Count of numShapes]]]
 
if (shape.ShapeType == ShapeType.NullShape)
{
continue;
}
 
288:
ShapeIndices.Add(shape);
 
293:
List<ShapeRange> shapes = ShapeIndices;
 
297:
for (int shp = 0; shp < numShapes; shp++)
{
ShapeRange shape = shapes[shp];
BOOM.
 
Fix (I think): line 297 should read:
for (int shp = 0 ; shp < shapes.Count ; shp++)
 
But I'm not a shapefile expert. It is worth taking a hard look at whether the code in the offending for loop also needs to execute for NullShape...(?)

New Post: Export to jpg

$
0
0
I need export map to jpg. How is possible ?

Source code checked in, #73590

$
0
0
Made changes so that the progress bar on the splash screen will be properly updated.

New Post: Export to jpg

Updated Release: DotSpatial 1.6

Edited Feature: Add WMS Support [22174]

$
0
0
We need to be able to display any map returned by an OGC WMS (Web Map Service) in the DotSpatial map control using the WebMap plugin. Currently the plugin only supports a list of predefined tile-map services, but not WMS.
 
The article:
http://www.codeproject.com/Articles/7199/Free-Maps-from-the-Web-Using-Web-Mapping-Service
gives a good overview of the WMS protocol and using it in c# / VB.NET
 
For testing - all functional WMS services that are listed in the catalog www.mapmatters.org
should be also displayable by the DotSpatial WebMap plugin.
 
Some other WMS service directories are:
http://www.perrygeo.net/wordpress/?p=35 (Top 10 WMS layers)
http://eusoils.jrc.ec.europa.eu/wms/wms.htm (European Soils WMS)
http://www.skylab-mobilesystems.com/en/wms_serverlist.html (any service from this list of WMS servers)
 
Related discussion on DotSpatial forum is:
http://dotspatial.codeplex.com/discussions/285009
 
Related HydroDesktop feature request is:
http://hydrodesktop.codeplex.com/workitem/4180
Comments: ** Comment from web user: mogikanin **

WebMap now supports a lot of WMS servers. I'm resolving this issue. Any issues\feature requests will be decorated as separated tasks.

Created Unassigned: Mono\Windows Plugins compatibily [25044]

$
0
0
Need to verify which plugins is Mono compatible and fix build paths.
Move to "Plugins" folder all plugins which working on both Windows and Mono.
Move to "Windows Extensions" all plugins which working only on Windows.

Commented Unassigned: Cross-thread operation not valid [24848]

$
0
0
I am attempting to reproject a raster. When I get to the point of output.saveas(outputfilename) I get a cross-thread error with the ribbonstatusbar (see below). Is there a way to work around this or fix it?


System.InvalidOperationException: Cross-thread operation not valid: Control 'ribbonStatusBar' accessed from a thread other than the thread it was created on.
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.PointToClientInternal(Point p)
at System.Windows.Forms.Control.PointToClient(Point p)
at DevExpress.XtraBars.Ribbon.ViewInfo.RibbonItemViewInfo.PointToClient(Point p)
at DevExpress.XtraBars.BarItemLink.ScreenToLinkPoint(Point p)
at DevExpress.XtraBars.ViewInfo.BarLinkViewInfo.get_MousePosition()
at DevExpress.XtraBars.ViewInfo.BarEditLinkViewInfo.CompareLinkState(BarLinkState newState, BarLinkState current)
at DevExpress.XtraBars.ViewInfo.BarLinkViewInfo.UpdateLinkState()
at DevExpress.XtraBars.BarItemLink.CheckUpdateLinkState()
at DevExpress.XtraBars.BarItemLink.LayoutChanged()
at DevExpress.XtraBars.BarItemLink.OnLinkChanged()
at DevExpress.XtraBars.BarItem.OnItemChanged(BarItemLink link, Boolean onlyInvalidate, Boolean onlyUpdateAppearance)
at DevExpress.XtraBars.BarItem.OnItemChanged(Boolean onlyInvalidate, Boolean onlyUpdateAppearance)
at DevExpress.XtraBars.BarItem.OnItemChanged(Boolean onlyInvalidate)
at DevExpress.XtraBars.BarEditItem.OnEditValueChanged()
at DevExpress.XtraBars.BarEditItem.set_EditValue(Object value)
at DotSpatial.RibbonHeader.Progress(String key, Int32 percent, String message)
at DotSpatial.Data.ProgressMeter.SendProgress()
at DotSpatial.Data.ProgressMeter.set_CurrentPercent(Int32 value)
at DotSpatial.Data.ProgressMeter.set_CurrentValue(Object value)
at DotSpatial.Data.Raster`1.GetStatistics()
at DotSpatial.Data.Raster.SaveAs(String fileName, String driverCode, String[] options)
at DotSpatial.Data.Raster.SaveAs(String fileName)
Comments: ** Comment from web user: mogikanin **

Hi, can you explain how to reproduce this issue? I tried to save raster in DemoMap and it working fine...

Viewing all 3973 articles
Browse latest View live


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