Forum > General

GIS Library for Lazarus

<< < (2/6) > >>

wp:
My corona application contains a mode in which data are plotted in a map with countries colored according to their infection level. At first, I wanted to read shape files directly, but then I decided against it because of the many interrelated files. I found the kml format to be more appropriate because it has everything in a plain xml structure. For those cases where I did not find kml files I used the QGIS application to convert shp to kml. And, if I remember correctly, this program also helped me to reduce the number of the polygon points of the country boundary down to some decent level (forgot how I did this - this is a non-trivial task...).

For drawing the country shapes I used TAChart. The version in laz/main contains a new TPolygonSeries which was intended to become the ancestor of the country plots. But since I wanted to be able to compile the application also in older Lazarus versions I copied this code into the corona project (unit cPolygonSeries). There is another unit cGeoMap which interfaces to GIS data files, extracts the country boundary polygons and feeds them into a polygon series (a TcGeoMapSeries, to be precise, because it needs some ID to identify the countries). There's also a variety of projections to project the spherical coordinates onto the screen plane (Mercator, Miller, orthographic plus some more). A separate reader unit is specialized to get the data from the kml files (cGeoMapReaderKML). Basically the structure is intended to be independent of kml. So, when you write a reader for SHP according to what the KML reader does the program should be able to display SHP files as well.

The entire code probably is not general enough for all-purpose GIS plotting, but you may get an idea how a standard TChart could be used for this purpose.

stab:
Hi again,

Here it comes together with two other components:
worldviewportroutines - can be used to display world-coordinates in a display
WGS84                      - transformation between WGS84 and coordinates in
                                   national coordinate-system.
                                   constants in the beginning is for the national system
                                   in Sweden, but can be reassigned.
                           
Salutes
stab :)

stab:
Forgot to answer your question:

Yes you can draw shapefiles in different colors on a canvas and have access to attributes

/stab

amir.eng:

--- Quote from: stab on January 13, 2022, 04:08:45 pm ---Hi again,

Here it comes together with two other components:
worldviewportroutines - can be used to display world-coordinates in a display
WGS84                      - transformation between WGS84 and coordinates in
                                   national coordinate-system.
                                   constants in the beginning is for the national system
                                   in Sweden, but can be reassigned.
                           
Salutes
stab :)

--- End quote ---

I took a look at the components, ShapeObj component is incredible !!, it also has some Arcmap's tools such as Merge or Split shapefiles , add or delete field or getting centroid of a polygon.
I was also looking for a component to convert UTM coordinates to LatLong, now I have it. Many thanks for your favor.

Could you please give me a simple example to create Poylgon shapefile for these coordinates ?? :

1) x = 1569.84, y = 1430.57
2) x = 1018.21, y = 1103.42
3) x = 958.40, y = 1404

My next question, is it possible to use Select By Attribute with the component similar Arcmap ?? For example I want to use this select : Select * from BuildingShape where village= 'Kayakoy'

* Also thanks to wp for replying. I downloaded Corona software , it's a good idea but I needed all-purpose GIS component.

 

stab:
Hi again,

I'm somewhat busy right now, but I'll be back next weeks with description an how to create, read/write,  select and display shapefiles.
Have written TShapeObj according shapefile format 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 welcomed to improve it.
As for your second question: It is possible to make the kind of selection your are asking for!

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version