DotSpatial / DotSpatial

Geographic information system library written for .NET
MIT License
881 stars 368 forks source link

If use NetTopologySuite data(not DotSpatial.NetTopologySuit), how to display it on the map control of DotSpatial? #1402

Closed BigBlueBob closed 2 years ago

BigBlueBob commented 3 years ago

DotSpatial version:2.0 For research needs, I converted shp/gdb/mdb into NetTopologySuite data, but I don’t know how to display it in MapControl. I see that the DotSpatial.NetTopologySuit library is included in DotSpatial, but this two seem to be different and cannot be converted to each other, and NetTopologySuite.Converter.DotSpatial cannot be used. I am now imitating the approach in DataManager.DefaultDataManager.OpenFiles(): get all the Vertices, generate ShapeRange and its PartRange, assign it to fs, and use Layers.Add(fs), but the data fs is not complete and the efficiency is low. Is there any existing method to display NetTopologySuite data in MapControl?

jany-tenaj commented 3 years ago

How did you convert your files to NetTopologySuite data? What exactly is NetTopologySuite data?

You can open Shapefiles directly with DotSpatial.

Based on the fact that DotSpatial.NetTopologySuite is a fork of NetTopologySuite you should be able to find the same ways to open your files with DotSpatial.NetTopologySuite.

Therefore converting NetTopologySuite to DotSpatial.NetTopologySuite is not supported.

BigBlueBob commented 3 years ago

For example, FeatureSet in DotSpatial.Data is a class that stores layer information including geometry and attributes. Open a shp, parse it into FeatureSet, and then use Layers.Add () to add it to the map and display it. And now I use GDAL's library to parse the layer into the FeatureCollection defined in NetTopologySuite.Features, which is similar to FeatureSet and stores the information of the layer. I call it NetTopologySuite data.

The reason why I use NTS to store data is that my leader wants to use this MapControl to open more types of graphic files, not just shp, such as gdb/mdb file, which I know DotSpatial may not support; the other is that NTS Dll contains some processing of layers. It's very convenient. (Perhaps DotSpatial also supports gdb/mdb and has a wealth of layer processing functions, but I haven't studied it thoroughly, my leader is now just designing it this way).

I understand what you mean, you mean I can also use DotSpatial.NetTopologySuite to open files and parse them, just like I use the NetTopologySuite. Then how do I use the MapControl to display them? With FeatureSet?

jany-tenaj commented 3 years ago

Check out the Getting started guide. This way you can create a program with a map. You can add FeatureSets you want to display via Map.MapFrame.Add. There are also other Add functions with the same effect.

Check out DotSpatial.Data.Rasters.GdalExtension to see how certain files can be added to the map from GDAL.

BigBlueBob commented 3 years ago

Thanks!

This really provides me with a new direction, I will go study it.