wfletcher / easygis.net Goto Github PK
View Code? Open in Web Editor NEWEasyGIS.NET source
License: GNU Lesser General Public License v3.0
EasyGIS.NET source
License: GNU Lesser General Public License v3.0
When entering a an invalid where clause and it displays the error correctly however after fixing the error it successfully selects or filters the entries but the previous error remains in the status bar
SFmap object correctly loads and displays SHP file type of PolygonZ.
As well, Function GetShapeIndiciesIntersectingCircle works fine.
However, Function GetClosestShape raises an Error.
In order to avoid issue I have introduced
Dim unsupportedSHPtypes() As String = {"PolygonZ"}
Might even add new unsupported types to settings or suggest conversion to Polygon because SFmap object reads and displays correctly.
How can I intersect a Shapefile with a polygon and get the records result?
I'm trying to plot a large amount of points into a SfMap
control. I have around 600+ points listed in a CSV file.
The points are listed by their longitude/latitude in a csv file.
I created a list of points which I draw onto my SfMap
with a for
loop. However, when I expect to see all 600 points plotted, I only see 30-40 actually shown on the map, in a grid-like pattern. It doesn't matter how much I zoom into the map, there are the same amount of dots. My longitude and latitude are very precise in the CSV file, with 600+ individual points (such as 131.6958, 32.506
). Although it takes on the general shape I am going for, it is not plotting all points. I'm sure this isn't an issue with the shapefile itself, as I've tried multiple ones.
I know this isn't an issue with the way I import the points into a list, I've checked.
I think this may be an issue on the SfMap1.GisPointToPixelCoord
function.
I checked the individual X, Y positions after the point conversion, they do account for zoom but they somehow don't account for all of the points. (There are 25 different longitude/latitude converted into the same X/Y, regardless of zoom).
The code looks like this:
'Loop in the SfMap's paint event.
For Each str As Tuple(Of String, String, Point, Point) In apiTimer.initialLocationDB
'The fourth Point variable stores the longitude/latitude data.
'I know there isn't anything wrong with the Tuple.
Dim pt As Point = Me.SfMap1.GisPointToPixelCoord(str.Item4.X, str.Item4.Y) 'Convert the Long/Lat to a Point
'Marker is then drawn using default function shown in an example.
Next
The output, somehow turning 600 points to only 30-40. Is there some limitation to the points drawn on the SfMap?
I was wondering if it might be possible to introduce some kind of display of M values for SFMap similar to ESRI's dynamic segmentation.
I'm currently using points to display the M value in EasyGIS, but I can only practically produce this point set for a subset of my network because of its size.
I realise there's probably a good reason why this isn't universally supported, but thought I'd chuck the suggestion in given ESRI's support seems to work pretty well, and EasyGIS rendering performance seems superior as well as your excellent support for the PolylineM.
Thanks for recent updates. Looks like time for my app to get an update with all the new features available
I noticed there was an EasyGIS package on Nuget:
https://www.nuget.org/packages/Huitian.EGIS.ShapeFileLib/
but based on the author's name & the age of the package, I'm guessing it might not be officially affiliated with this project. (Not that there is anything wrong with that package as far as I can see, but I didn't look closely).
Interestingly it shows nearly 13K downloads, which I think is an indicator in the amount of interest in this project! I have been using it from source (added the project to my solution) which works but a Nuget package would be a lot more convenient - saving build time and also alerting (in a sense) when updates become available.
That said, I don't know how much work it is to publish that way, so maybe this is asking a lot...
When the Proj CRS type is PJ_TYPE_BOUND_CRS the EPSG Id is not identified when loading from WKT.
An example CRS is Slovenia 1996 / Slovene National Grid (EPSG ID 3794).
Hi Winston!
Can you provide a example for custom labels?
Thank you!
EGIS currently uses PROJ 6.1. Upgrading to Proj9.0 will support more projections and take advantage of new features.
For Australia transforming from GDA94 to GDA2020 is supported correctly using 9.0 (possible fixed in versions > 7.x)
Step 1:
SFmap contains raster map EPSG 3912
The following Shp files are created:
2 points polyline represents distance leg created in Orthogonal Mode. The Left and right Y coordinates are identical.
Labeled by magnetic north declination, leg length, and the sum of previous legs lengths.
Step 2:
Switching the raster map from EPSG 3912 to Web Maps (Pseudo Mercator), Polyline disappears. Red Point remains.
Step 3:
Switching back to the raster map EPSG 3912 polyline reappears.
For editing purposes, I use pressed CTRL or Shift Key respectively to achieve bespoke functionality
SFmap object uses both Keys to Show the Selection rectangle/circle.
Is there a way to disable drawing Selection rectangle/circle in pan mode while CTRL or Shift Key is pressed?
I use the left and right mouse buttons to pan a map.
If my selection mode or drawing mode is pending then only the right mouse bottom performs panning.
If the left mouse is pressed in either mode panning mode is set to None.
I managed to bring the SFmap object to an internal state where the SFmap selection rectangle was showing without CTRL or Shift Key pressed. Unfortunately, I did not press and release either CRTL or Shift to potentially bring the internal SFmap to the correct state.
Hello all,
I'm working on a GPS based runtime data collector, now I'm able to create a stream for my shape files.
My next goal is to update runtime one or more records of this stream without destroy and recreate it every time (SfMap.RemoveShapeFile and SfMap.AddShapeFile), because this happens more times and it causes a flash on GUI.
I would to do somthing similar to SFMap.SetRecordVisibility, to change, in my case, the inner color of a rectangle.
Is it possible to do it?
Thanks.
Rob.
I have added the ability to allow the user to draw a polygon with the intention that any objects intersecting the shape are marked as selected. The resulting selection is not very accurate. I have tracked the issue down to the NativeMethods.PolyLinePolygonIntersect call, but it is years since I worked with C++ so wondered if someone else could look at this.
My polygon is a bowtie shape which probably contributes the problem, but non crossing polygons also cause me intersection issues.
I have a NUnit based unit test project to highlight the problem which I have attached. If you execute these tests you will see that the individual points of the line fall within the polygon but when the polyline is assessed it does not.
Hi
Is there a way to connect this project to GMAP.net so I can utilize GMAP.net to show the vectors from EasyGIS.NET when loading from shape files?
Best
Christian
Hello, is there a method of drawing circles on the EASYGIS.NET SFMAP Control? I would like to be able to draw a circle with a certain center point (lat/long) and a radius in Kilometers. Is there a way to accomplish this in easygis.net? I haven't seen an example that shows drawing circles with the SFmap.
I installed out app on a clean Windows 10 PC and discovered that the CRS Selection form was not populated with CRS data. The Proj6 folder and its contents were present.
After some experimentation I discovered I needed to install the 'Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019'. I think it might be helpful to add redistribution section to the README.md or wiki and list the above as a requirement to save other people having to search for it.
This is a link to the data I have tested.
https://api.os.uk/downloads/v1/products/OpenRivers/downloads?area=GB&format=ESRI%C2%AE+Shapefile&redirect
Link represents UK rivers body. Individual record spans just a small area = boundary rectangle is less than 1000 m in most cases.
If I use GetShapeBounds method to get record boundary to check if it fits my target rectangle the following image appears.
The image was rotated to save web page space.
Please note red records outside Focus Rectangle. They should not be there.
If I calculate records Bounds by iterating through all Record Points seeking X,Y Min Max the image is the following.
The result is correct.
The final test shows GetShapeBounds instead of records. For better illustrative purposes Focus Rectangle is horizontally oriented.
Indicating there might be a bug in GetShapeBounds Method. (Actually, it is GetRecordBounds Method).
I hope this helps in checking if a bug in the method GetShapeBounds exists.
I wont to use the GeometryAlgorithms.PointInPolygon-function in a shapefile. The PointInPolygon-function need type EGIS.ShapeFileLib.PointD[], but ShapeFileEnumereator or GetShapeDataD returns ReadOnlyCollection<PointD[]> and I get error if I use that in the function.
Is there an example of this, to use the PointInPolygon-function in a shapefile?
Thanks!!
An issue regarding concurrent multiple EPSG has been detected in my Project.
Explanation:
SFmap object shows two SHP files Easy in GIS.NET Desktop Edition
Uk Rivers and Slovene administrative units.
Tooltip in Easy GIS.NET Desktop Edition displays Record info correctly.
The following function in my project
also returns correct Records.
However, the following function
returns UK Records while the mouse is placed over Slovene territory in my project. The thing is that UK coordinate values have similar values to Slovene coordinates.
Observation: Easy GIS.NET Desktop Edition probably does not use the second function.
The first function takes EPSG into account, while the second one does not.
It appears that the second function takes all coordinates (regardless of EPSG) to calculate RecordIndex.
Adding SFmap MapCoordnateSystem as an Optional parameter to the second function might be the solution.
EGIS.Projections CRS WKT uses the 2018 WKT2 simplified convention used by proj6.
Some GIS applications may not recognize the 2018 format (for example some versions of QGIS does not load the prj WKT in this format), To overcome this an EGIS CRS should have a method added to specify which WKT format to output.
We have a requirement to change the direction arrows based on the movement direction along a line rather than the drawn direction.
I have implemented this by adding a GetDirection() function to ICustomRenderSettings. The function should return 1 for drawn direction; -1 to reverse the direction arrow and 0 to not draw the direction on that line.
If you would like this I can create a pull request otherwise I will maintain is on my fork.
Is it possible to "force" to write an EGP file to a string?
And by the same token, is it possible to populate Rendeder from a string?
This code fails when running as 32bit.
byte** options = stackalloc byte*[1];
options[0] = ptr;
byte* wkt = proj_as_wkt(ctx, pj, type, options);
solution is to create an array and pin it with a fixed statement,
byte*[] optionsArray = new byte*[1];
optionsArray[0] = ptr;
fixed (byte** options = optionsArray)
{
byte* wkt = proj_as_wkt(ctx, pj, type, options);
return wkt != null ? new string((sbyte*)wkt) : null;
}
It would be useful to know the location of the double click event (and the mouse button states) outside the SFMap control.
If this could be changed to use Path.DirectorySeparatorChar then this would work across platforms on mono/etc
I'm trying to render a shapefile's specific items by record types in a .DBF file.
I tried to use example 8 sample project's code in my projects, but couldn't get my shapefile to render lines by a specific color.
My ShapeFile is not a collection of polygons, but rather a collection of lines.
The DBF file looks something like this:
I try to load the ShapeFile like this:
Dim path As String = Application.StartupPath & "\assets\gisdata\tsunami\testShapeFile.shp"
Dim sf As EGIS.ShapeFileLib.ShapeFile = Me.SfMap1.AddShapeFile(path, "ShapeFile", "name")
sf.RenderSettings.FieldName = "name"
sf.RenderSettings.Font = New Font(Me.Font.FontFamily, 12)
Dim colors As Dictionary(Of String, Color) = New Dictionary(Of String, Color)()
colors.Add("Region1", Color.Green)
Dim rs As RoadTypeCustomRenderSettings = New RoadTypeCustomRenderSettings(sf.RenderSettings, "name", colors)
sf.RenderSettings.CustomRenderSettings = rs
sf.RenderSettings.UseToolTip = True
sf.RenderSettings.ToolTipFieldName = "name"
sf.RenderSettings.MaxPixelPenWidth = 20
sf.RenderSettings.IsSelectable = True
I have a class with these functions that looks like this:
Imports EGIS.ShapeFileLib
Class RoadTypeCustomRenderSettings
Inherits BaseCustomRenderSettings
Private colorList As List(Of System.Drawing.Color)
Public Sub New(ByVal defaultSettings As RenderSettings, ByVal typeField As String, ByVal roadtypeColors As Dictionary(Of String, System.Drawing.Color))
MyBase.New(defaultSettings)
BuildColorList(defaultSettings, typeField, roadtypeColors)
End Sub
Private Sub BuildColorList(ByVal defaultSettings As RenderSettings, ByVal typeField As String, ByVal roadtypeColors As Dictionary(Of String, System.Drawing.Color))
Dim fieldIndex As Integer = defaultSettings.DbfReader.IndexOfFieldName("NAME")
If fieldIndex >= 0 Then
colorList = New List(Of System.Drawing.Color)()
Dim numRecords As Integer = defaultSettings.DbfReader.DbfRecordHeader.RecordCount
For n As Integer = 0 To numRecords - 1
Dim nextField As String = defaultSettings.DbfReader.GetField(n, fieldIndex).Trim()
Console.WriteLine("FINDING: " & nextField)
If roadtypeColors.ContainsKey(nextField) Then
colorList.Add(roadtypeColors(nextField))
MsgBox("FOUND")
Else
'If it is not found, use a red color.
Dim defColor = Color.FromArgb(255, 0, 0)
' colorList.Add(defaultSettings.FillColor)
colorList.Add(defColor)
End If
Next
End If
End Sub
Public Overrides Function GetRecordFillColor(ByVal recordNumber As Integer) As System.Drawing.Color
If colorList IsNot Nothing Then
Return colorList(recordNumber)
End If
Return renderSettings.SelectOutlineColor
End Function
End Class
Class POICustomRenderSettings
' Inherits ICustomRenderSettings
Private imageList As List(Of System.Drawing.Image)
Private defaultSettings As RenderSettings
Public Sub New(ByVal defaultSettings As RenderSettings, ByVal typeField As String, ByVal poiImages As Dictionary(Of String, System.Drawing.Image), ByVal defaultImage As System.Drawing.Image)
Me.defaultSettings = defaultSettings
BuildPOIList(defaultSettings, typeField, poiImages, defaultImage)
End Sub
Private Sub BuildPOIList(ByVal defaultSettings As RenderSettings, ByVal typeField As String, ByVal poiImages As Dictionary(Of String, System.Drawing.Image), ByVal defaultImage As System.Drawing.Image)
Dim fieldIndex As Integer = defaultSettings.DbfReader.IndexOfFieldName(typeField)
If fieldIndex >= 0 Then
imageList = New List(Of System.Drawing.Image)()
Dim numRecords As Integer = defaultSettings.DbfReader.DbfRecordHeader.RecordCount
For n As Integer = 0 To numRecords - 1
Dim nextField As String = defaultSettings.DbfReader.GetField(n, fieldIndex).Trim()
If poiImages.ContainsKey(nextField) Then
imageList.Add(poiImages(nextField))
Else
imageList.Add(defaultImage)
End If
Next
End If
End Sub
Public Function GetRecordFillColor(ByVal recordNumber As Integer) As System.Drawing.Color
Return defaultSettings.FillColor
End Function
Public Function GetRecordFontColor(ByVal recordNumber As Integer) As System.Drawing.Color
Return defaultSettings.FontColor
End Function
Public Function GetRecordImageSymbol(ByVal recordNumber As Integer) As System.Drawing.Image
Return imageList(recordNumber)
End Function
Public Function GetRecordOutlineColor(ByVal recordNumber As Integer) As System.Drawing.Color
Return defaultSettings.OutlineColor
End Function
Public Function GetRecordToolTip(ByVal recordNumber As Integer) As String
Return ""
End Function
Public Function RenderShape(ByVal recordNumber As Integer) As Boolean
Return True
End Function
Public Function GetRecordLabel(ByVal recordNumber As Integer) As String
Return ""
End Function
Public Function GetDirection(ByVal recordNumber As Integer) As Integer
Return If(defaultSettings.DrawDirectionArrows, 1, 0)
End Function
Public ReadOnly Property UseCustomImageSymbols As Boolean
Get
Return True
End Get
End Property
Public ReadOnly Property UseCustomTooltips As Boolean
Get
Return False
End Get
End Property
Public ReadOnly Property UseCustomRecordLabels As Boolean
Get
Return False
End Get
End Property
End Class
When I run the application, I sucessfully get the message boxes which tell me that the record was found. However, I cannot color the specific element rendering on the SFMAP. I also know that the lines are being rendered correctly, as if I hover over the lines, a popup shows with the item's name ("Region1").
However, when the map renders, I don't get any green lines, but only gray lines.
How can I render specific items on the SFMAP with a different color by a name in the shapefile's DBF file?
We talk about it some time ago.
When we change the zoom/position, the tiles are requested asynchronously and loaded onto the screen when the download is complete. Although it is not a queue, they are requests awaiting completion. If we change the zoom/position before these tiles are loaded, a new list of requests is made. So on for each changed zoom/position.
It turns out that depending on the internet connection speed or server demand, the tiles take a long time to be downloaded and shown on the screen.
Analyzing the code, I was thinking about it and I think a solution would be to abort the requests when the zoom/position is changed.
It would make the map display faster.
I did some tests with CancellationTokenSource but I could'nt good results. Anyway I think that's a good way to solve this. Probably I did something wrong on implementation.
Well, this is a important thing to think when we talk about implementation of EGIS on web applications.
Thank you for this great job on EGIS!
It appears that new SHP object property or method is needed.
It is nice to have individual record visibility available.
However, if there are loads of Records then SHP.Show and SHP.Hide would be just great.
If SHP visibility is set to Hide then no Records are displayed. Regardless if they are set to be Visible.
In most cases the function works as expected, but due to the way records are indexed using a quad tree structure a record may be missed due to the pt + delta check. Records are first checked using the quad tree by determining if the quad tree children contain the point.
To fix this need to create a rectangle using point + delta and check if this rectangle intersects with quad tree children
I am using the mouse wheel for editing purposes as well.
For example, to rotate a text before placing it on a map.
Is there a way to disable Zooming?
I managed to compensate Zooming effect but it requires a full refresh.
Regards
Hi,
is it possible to get streams from the SHP file that was already added to the SFmap object?
The reason: writing SHP structure to the database by converting streams to byte arrays first and then writing to BLOB fields.
I understand that byte arrays of streams can be maintained during the lifetime of a shapefile, however, getting memory streams from the existing shapefile file would be very elegant.
I have just tried to run the web demo from a clone of the repository. There are a lot of files missing from the demos folder.
I think the issue lies with the gitignore file. I'm not sure how to add exceptions for file types for specific folders but I think that would allow you to commit all the required files.
I have an older copy so could restore them. The following is the list of the files currently missing from the repo:
demo2.egp
demo2_files/
us_demo.egp
us_demo_files/cities.dbf
us_demo_files/cities.shp
us_demo_files/cities.shx
us_demo_files/counties.dbf
us_demo_files/counties.shp
us_demo_files/counties.shx
us_demo_files/lakes.dbf
us_demo_files/lakes.shp
us_demo_files/lakes.shx
us_demo_files/states.dbf
us_demo_files/states.shp
us_demo_files/states.shx
world.egp
world_files/world_adm0.dbf
world_files/world_adm0.shp
world_files/world_adm0.shx
This bug was introduced in 4.7.1 and is related to expanding the render size in the SFMap to avoid drawing outline of cropped shapes on borders Only affects desktop edition.
Hi,
It may be be me doing something wrong but I'm finding that when:
`sfMap1.UseMercatorProjection = true;`
If I bring in a shp file using a different CRS (BritishNationalGrid in my instance) the shapes are invisible. They are there because I can see the cursor showing data form the shapes (not sure if they are in the right place or not, I'm not sure if the conversions automatic or not).
If I set:
`sfMap1.UseMercatorProjection = false;`
Then the shp file is perfectly visible.
I've asked the question here but not getting any answers.
The is more detail in the StackOverflow quesiton.
Example 6 behaves the same way.
Thanks for any help.
Add these properties to restrict zooming in too far on a map
Extending on the topic of drawing custom objects on the SFmap control with the paint event, is there a way to convert a distance (of KM) to the number or length of pixel points of a current SFmap control? Is there a function that does this?
I’m trying to do this, but I have to convert one random longitude and latitude point to a SFmap pixel point, choosing another random longitude and latitude point exactly that amount of KM away, and converting that to a SFmap pixel point, finally subtracting the distance between the two pixel points to get a relative distance from KM to SFmap pixels, is there another easier way to do this? (The functions mentioned here are https://easygis.net/api/output/html/M_EGIS_Controls_SFMap_GisPointToPixelCoord_1_cfca3a5a.htm)
I didn’t find a function for doing this in the SFmap reference, and I don’t have a working method for doing my method (in the second paragraph with .NET anyways). Is there a way I can do this with SFmap (converting distance in KM to number of pixel points) or using my method described in the second paragraph?
Any help would be appreciated!
Currently the ShadowTextColor always sets the color alpha component to 255 before rendering. This restriction should be removed and use the color set in the RenderSettings including any alpha component
RenderSettings MinZoomLevel, MaxZoomLevel, PenWidthScale control whether a layer is drawn and thickness of polylines. If the properties are set and then the map is switched from a geodetic crs to a projected crs then the properties should be updated so that the rendering is not affected. For example if the rendersettings are created while the map was using WGS84 crs and then the map is changed to pseudo web mercator then the layers may not be drawn or the polyline pen width wlll be to large
I have an issue docking SFmap object between Menu Strip (on the top) and Status Strip (at the bottom). Tried all imaginable tricks found on Stackoverflow and elsewhere. I would like to place SFmap properly between Menu and Status Strip. Tried to use a panel as well.
But nothing works. The best outcome is proper docking in relation to Menu Strip. But SFmap always "goes" behind Status Strip and spans to Form bottom. Docking in runtime does not help either. Bringing to front and sending to back has no satisfactory effects. In design and in runtime alike. There are some indications that this is a Microsoft bug that lasts for ages. I am using VS 2017.
Any idea perhaps?
Hello, I've been receiving this error for the past few days. (Note: Example 5 works by itself).
I've been trying to implement example 5 into another .NET application language (VB.NET
) but I've received the error:
Exception thrown: 'System.OutOfMemoryException' in EGIS.ShapeFileLib.dll
An unhandled exception of type 'System.OutOfMemoryException' occurred in EGIS.ShapeFileLib.dll
I'm not sure whats going on, as I believe I imported all libraries correctly. Is there any libraries/other files in the Example 5 source code (other then the DLLs) that are required to be imported? I don't understand why this is happening.
I render my shapefile like this:
SfMap1.ClearShapeFiles()
SfMap1.AddShapeFile("C:\Users\admin\assets\boundry.shp", "ShapeFile", "")
I’m attempting to draw a moving object on a SFmap. I’m trying to make a rectangle that expands in size smoothly using the SFMAP paint event. (as in increasing size every by 1px every 10ms).
I increase the size with a timer set at a tick interval rate of 10 which adds 1 to a variable containing the rectangle’s width. The paint event on the SFMAP will draw a rectangle (for example) with a demo width incremented smoothly by a timer.
However, if I call the invalidate event on the SFMAP (to apply the rectangle’s width changes) with the timer, it becomes slow and impossible to use. Is there a way that I can draw a smooth moving object on a SFMAP without the control it lagging or taking up too much memory?
Until today I only worked with maps that I created, saved and then opened.
My idea is to create maps and load them, without saving them. I think I would have better management of these temporary maps that today I create, save and open.
I used the example of stream in MainForm.cs and it worked correctly. However, that example duplicates a loaded map. I was unable to change it to create a map and leave it in memory, then load it from the stream.
It would be great if there was a method to create shapefiles of lines, points and polygons and leave them in memory, or even load them on the map.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.