how create a layer with longitude and latitude with features

Topics: General Topics
Apr 3, 2007 at 12:15 PM
how create a layer with longitude,latitude and features?
this example only create layer without features
List<SharpMap.Geometries.Geometry> geometries = new List<SharpMap.Geometries.Geometry>();
//Add two points
geometries.Add(new SharpMap.Geometries.Point(23.345,64.325));
geometries.Add(new SharpMap.Geometries.Point(23.879,64.194));
SharpMap.Layers.VectorLayer layerVehicles = new SharpMap.Layers.VectorLayer("Vechicles");
layerVehicles.DataSource = new SharpMap.Data.Providers.GeometryProvider(geometries);
layerVehicles.Style.Symbol = Bitmap.FromFile(@"C:\data\car.gif");
myMap.Layers.Add(layerVehicles);
Coordinator
Apr 3, 2007 at 12:57 PM
This looks correct. The result is a layer with two point features. In fact, I tried this code and it works... remember to add a myMap.ZoomToExtents() call to get the added point features into view.
Apr 3, 2007 at 1:42 PM
Edited Apr 3, 2007 at 1:52 PM

codekaizen wrote:
This looks correct. The result is a layer with two point features. In fact, I tried this code and it works... remember to add a myMap.ZoomToExtents() call to get the added point features into view.

my english language is not good .my purpose is how create a layer with x,y
coordinates and its attribute for example table of earthquake event to a layer.

longitude latitude magnitude region date
40 50 6 iran 4.2.2006
35 45 5 pakistan 2.4.2005
Coordinator
Apr 3, 2007 at 4:51 PM
Ah, I see. You want to use attributes with the GeometryCollection provider. I'm sorry to say that this isn't supported in v0.9. There is a workitem for this (Create FeatureProvider for dynamically created, in-memory layers) which looks to be quite popular.

It looks like it wouldn't be very hard to add support, but non-trivial enough that I couldn't spend time on it soon. If you are interested in implementing it, I'd give you whatever guidance you'd need and add your patch into the project.
Apr 16, 2007 at 4:23 AM
I got the same problem , i need to draw some points using the above code but with world cordinate(lon,lat),i tried to use the cordinate conversion (worldToImage)but failed,bcoz it require pointf, help with the solution


codekaizen wrote:
Ah, I see. You want to use attributes with the GeometryCollection provider. I'm sorry to say that this isn't supported in v0.9. There is a workitem for this (Create FeatureProvider for dynamically created, in-memory layers) which looks to be quite popular.

It looks like it wouldn't be very hard to add support, but non-trivial enough that I couldn't spend time on it soon. If you are interested in implementing it, I'd give you whatever guidance you'd need and add your patch into the project.