Recent

Author Topic: GIS Library for Lazarus  (Read 13111 times)

amir.eng

  • Jr. Member
  • **
  • Posts: 99
Re: GIS Library for Lazarus
« Reply #15 on: January 19, 2022, 06:31:42 am »
Great, I check it out and also tools.

Few issues:

-Parcels border are not clear when Outline mode is diabled (Please take a look at the attached image, the left shape file is in Arcmap and the right one is the same shape file in the Application)
-Is it possible to add Zoom In and Zoom Out to the main shape view window?
-Is it possible to select feature by clicking on the main shape veiw window and showing only the feature's attributes on the shapetable ?
« Last Edit: January 19, 2022, 06:34:03 am by amir.eng »
Lazarus 3.0 , FPC 3.2.2 , Windows 10 64, Excel 2016 64

zamtmn

  • Hero Member
  • *****
  • Posts: 594
Re: GIS Library for Lazarus
« Reply #16 on: January 19, 2022, 08:55:09 am »
There is also such an variant, it does not directly supports SHP, but a lot has been done in it for fast processing of vector graphics

stab

  • Full Member
  • ***
  • Posts: 234
Re: GIS Library for Lazarus
« Reply #17 on: January 20, 2022, 12:04:08 am »
Regarding your question:
Is it possible to select feature by clicking on the main shape veiw window and showing only the feature's attributes on the shapetable ?

Should I understand this so:
 you would like that only attributes for selected shape is displayed?

Regarding border not clear:
  Have to look at that little more

Working on zoomin, zoomout and pan

loaded

  • Hero Member
  • *****
  • Posts: 824
Re: GIS Library for Lazarus
« Reply #18 on: January 20, 2022, 08:18:58 am »
-Parcels border are not clear when Outline mode is diabled (Please take a look at the attached image, the left shape file is in Arcmap and the right one is the same shape file in the Application)
Regarding border not clear:
  Have to look at that little more

By the way, I can say with the experience I gained from a CAD application that I designed in Android Studio, the backbone of which I wrote with Lazarus+LAMW;
Defining the brush and pen colors separately will solve the problem.

Related application usage test video;
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

amir.eng

  • Jr. Member
  • **
  • Posts: 99
Re: GIS Library for Lazarus
« Reply #19 on: January 20, 2022, 11:56:55 am »
Regarding your question:
Is it possible to select feature by clicking on the main shape veiw window and showing only the feature's attributes on the shapetable ?

Should I understand this so:
 you would like that only attributes for selected shape is displayed?

Regarding border not clear:
  Have to look at that little more

Working on zoomin, zoomout and pan
Yes I mean the table shows only attribute for selected shape like Arcmap.
Could you please add zoomin, zoomout,pad, selecting feature by mouse ??
Lazarus 3.0 , FPC 3.2.2 , Windows 10 64, Excel 2016 64

stab

  • Full Member
  • ***
  • Posts: 234
Re: GIS Library for Lazarus
« Reply #20 on: January 20, 2022, 12:43:05 pm »
Regarding selecting feature by mouse, you have it already, just check HitTest and click in a shape. In the version you have right now, all features will show up, but current attribute is marked. I've a new version where just attributes for the selected is shown.
Working on  zoomin, zoomout,pan and your problem with somewhat jagged borders.

stab

  • Full Member
  • ***
  • Posts: 234
Re: GIS Library for Lazarus
« Reply #21 on: January 26, 2022, 06:48:04 pm »
Have been testing quite a bit to achieve fast drawing, am not satisfied but
think someone smarter than me have to fix that.

You now have zoom, pan and antialiasing.

Included in the zip file is a new component ShapeObBGRA that draws on a
TBGRAGraphicControl that handles antialiasing and removes jagged borders.

If you or someone else improves the component I'd be glad to have a copy.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: GIS Library for Lazarus
« Reply #22 on: January 26, 2022, 07:43:20 pm »
@stab

Hi!

You forgot the dir auxiliary with the file shapeobjbgra.pas  in your zip file.

Winni

stab

  • Full Member
  • ***
  • Posts: 234
Re: GIS Library for Lazarus
« Reply #23 on: January 26, 2022, 10:04:23 pm »
Sorry, new zip file included test shapefile :o

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: GIS Library for Lazarus
« Reply #24 on: January 27, 2022, 12:04:00 am »
Hi!

First shot:

Code: Text  [Select][+][-]
  1. ShapeObj.pas(5595,58) Error: Call by var for arg no. 5 has to match exactly: Got "Double" expected "Extended"
  2.  

On Linux64

Winni

stab

  • Full Member
  • ***
  • Posts: 234
Re: GIS Library for Lazarus
« Reply #25 on: January 28, 2022, 02:03:05 pm »
As I wrote earlier:
Have written TShapeObj according the shapefile format description and it has served my purposes well. It is not optimized and when some new need has showed up it has been expanded.
Anyone is welcome to improve it. If so, I'm interested in getting a copy.

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: GIS Library for Lazarus
« Reply #26 on: October 08, 2022, 02:32:49 pm »
G'day,

Sorry for bumping an old post, but this seems the most appropriate location.

Many thanks for this library.  Honestly, I couldn't have solved some issues on this job without it.  My use is with the WGS84 unit.  I'm not a surveyor, but in my industry we use Eastings, Northings extensively.  I've been tasked with sending a device a GPS signal, so I needed to convert from EN to LatLon (cause I only know GPS commands that contain Lat Lon).

I've got everything working, and the conversion in WGS84 checks out against empirical data.  So chances are, my question here is about convention.

I've noticed two oddities when using WGS84.pas.   
1.  In the comments for WGS84.pas, UTM.X is Easting, and UTM.Y is northing.  And that makes sense.  In my code though, I only get everything working if I use UTM.Y as Easting and UTM.X and northing.

2.  Northing is coming out with a negative sign.  Sure, I'm in the southern hemisphere, so this kind of makes sense.  Except I've never seen negative northings in use in any field (I work in subsea oil and gas).  And there's already a UTM.southernhemi boolean which I thought would take care of this.

My question is: Am I using WGS84.pas incorrectly, and I misunderstanding survey coordinates?, or is there an issue in WGS84.pas?

In the test code that follows, I ask the user to enter a Lat Lon.  This is then used to determine the UTM Zone (UTM.Fuseau) and determine if we're in the SouthernHemisphere.
I then convert this LAt Lon to Easting, Northing, and display that in my UI
I then convert back to Lat Lon (as a test) and display that.

I have a support unit (GSPSupport.pas) really so I can simplify code elsewhere by using a singleton for TWGS84.

Here's relevant snippets of my code:

MainForm
Code: Pascal  [Select][+][-]
  1.  
  2.   InitialiseGPS(edtLatitude.Value, edtLongitude.Value);
  3.  
  4.   LatLonToEN(edtLatitude.Value, edtLongitude.Value, dEast{%H-}, dNor{%H-});
  5.   ENToLatLon(dEast, dNor, dLat{%H-}, dLon{%H-});
  6.  
  7.   memGPS.Lines.Add('Original Lat:%.6f, Long:%.6f', [edtLatitude.Value, edtLongitude.Value]);
  8.   memGPS.Lines.Add('E:%.2f, N:%.2f', [dEast, dNor]);
  9.   memGPS.Lines.Add('Converted Lat:%.6f, Long:%.6f', [dLat, dLon]);  
  10.  

GPSSupport.pas
Code: Pascal  [Select][+][-]
  1. Var
  2.   FWGS84: TWGS84;
  3.   FFuseau: Integer;
  4.   FSouthernHemi: Boolean;
  5.  
  6. Function GetWGS88: TWGS84;
  7. Begin
  8.   If Not Assigned(FWGS84) Then
  9.     FWGS84 := TWGS84.Create;
  10.  
  11.   Result := FWGS84;
  12. End;  
  13.  
  14. Procedure InitialiseGPS(ALat, ALon: Double);
  15. Begin
  16.   FFuseau := floor((ALon + 180) / 6) + 1;
  17.   FSouthernHemi := (ALat < 0);
  18. End;  
  19.  
  20. Procedure LatLonToEN(ALat, ALon: Double; Var AEast, ANorth: Double);
  21. Var
  22.   oLatLon: TrecLatLon;
  23.   oUTM: TrecUTM;
  24.   oWGS84: TWGS84;
  25. Begin
  26.   oLatLon.Lat := ALat;
  27.   oLatLon.Lon := ALon;
  28.  
  29.   oWGS84 := GetWGS88;
  30.   oWGS84.WGS84ToUTM(oLatLon, oUTM{%H-});
  31.  
  32.   AEast := oUTM.Y;
  33.   ANorth := oUTM.X;
  34. End;
  35.  
  36. Procedure ENToLatLon(AEast, ANorth: Double; Var ALat, ALon: Double);
  37. Var
  38.   oLatLon: TrecLatLon;
  39.   oUTM: TrecUTM;
  40.   oWGS84: TWGS84;
  41. Begin
  42.   If FFuseau = -1 Then
  43.     Raise Exception.Create('Fuseau (UTM Zone) not defined.  Call InitialiseGPS first.');
  44.  
  45.   oUTM.X := ANorth;
  46.   oUTM.Y := AEast;
  47.  
  48.   oUTM.southhemi := FSouthernHemi;
  49.   oUTM.fuseau := FFuseau;
  50.  
  51.   oWGS84 := GetWGS88;
  52.   oWGS84.UTMToWGS84(oUTM, oLatLon{%H-});
  53.  
  54.   ALat := oLatLon.Lat;
  55.   ALon := oLatLon.Lon;
  56. End;      
  57.  
  58. Initialization
  59.   FWGS84 := nil;
  60.   FFuseau := -1;
  61.   FSouthernHemi := True;
  62.  
  63. Finalization
  64.   FreeAndNil(FWGS84);        

And finally, here's the output from the above:
Quote
Original Lat:-19.809287, Long:114.608388
E:249468.54, N:-7807850.06
Converted Lat:-19.809287, Long:114.608388

I haven't checked if the Easting/Northing is mm accurate, I only need accuracy to metre.   Other than the minus sign, the E N checks out.
As you'll see, in Procedures ENToLatLon & LatLontoEN I had to switch X & Y around for Easting & Northing
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

loaded

  • Hero Member
  • *****
  • Posts: 824
Re: GIS Library for Lazarus
« Reply #27 on: October 08, 2022, 08:41:26 pm »
I haven't checked if the Easting/Northing is mm accurate, I only need accuracy to metre.   Other than the minus sign, the E N checks out.
As you'll see, in Procedures ENToLatLon & LatLontoEN I had to switch X & Y around for Easting & Northing

You can control the conversions between units from the relevant site.
https://twcc.fr/
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: GIS Library for Lazarus
« Reply #28 on: October 08, 2022, 08:51:43 pm »
You can control the conversions between units from the relevant site.
https://twcc.fr/

Thanks.  But that appears to be a web based solution.  I've already confirmed the coordinates are correct. 

My issue is that in order to generate the correct coordinates, I had to cross the use of X and Y when passing to WGS84.pas.

This worked
Code: Pascal  [Select][+][-]
  1.   oUTM.X := ANorth;
  2.   oUTM.Y := AEast;

This didn't
Code: Pascal  [Select][+][-]
  1.   oUTM.X := AEast;
  2.   oUTM.Y := ANorth;

So, is this an issue with WGS84.pas, or am I misunderstanding something about GIS coordinates?  I have no survey training, so this latter is a real possibility.
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

loaded

  • Hero Member
  • *****
  • Posts: 824
Re: GIS Library for Lazarus
« Reply #29 on: October 08, 2022, 09:54:04 pm »
It seems to me that it is necessary to check the formulas for the use of x and y.
The related site is using proj4 for conversion. This is what the conversion values look like.
It seems like there is some difference.

Code: Pascal  [Select][+][-]
  1. GPS (WGS84) (deg) to GPS (WGS84) (UTM)
  2. Lat =-19.809287°N      Lng =114.608388°E
  3. Hemisphere =South       Zone =50        X =     249468.543 m    Y =7807850.062 m
  4.  

Code: Pascal  [Select][+][-]
  1. GPS (WGS84) (UTM)  to GPS (WGS84) (deg)
  2. Hemisphere =South       Zone =50        X =249468.543 m         Y =-7807850.062 m
  3. Lat =-19.772537982827114°N     Lng =-60.60893696769726°E

I have no survey training, so this latter is a real possibility.

I don't have surveyor training either.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

 

TinyPortal © 2005-2018