Hello,
I am curious if the default projection for WpfMap is EPSG:4326.
We load a few shapefiles which have no .prj files and it looks like the projection used is EPSG:4326
Is that correct?
Thanks
Thomas
Hello,
I am curious if the default projection for WpfMap is EPSG:4326.
We load a few shapefiles which have no .prj files and it looks like the projection used is EPSG:4326
Is that correct?
Thanks
Thomas
Thomas,
Thanks for your post, actually, the if the shape file which has no .prj file, the MapSuite always uses the EPSG:4326 as the default projection for the shape file. The EPSG:4326 is the default projection for all map controls of ThinkGeo.
Any more questions please let me know,
Thanks,
Scott,
Thanks Scott,
So is the default projection determined depending on wheter I do:
wpfMap1.MapUnit = GeographyUnit.Meter;
or
wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
?
Reason I ask is that drawing an circle using
wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
…
EllipseShape ellipse3 = new EllipseShape(new PointShape(-90, 80), 45000, 45000, GeographyUnit.DecimalDegree, DistanceUnit.Meter);
Creates a flattened circle which seems to be consistent with EPSG:4326 as you stated.
But when I do:
wpfMap1.MapUnit = GeographyUnit.Meter;
EllipseShape ellipseCloseToBase = new EllipseShape(new PointShape(-10018754.1714,15538711.0963), 45000, 45000, GeographyUnit.Meter, DistanceUnit.Meter);
(-10018754.1714,15538711.0963 is same location as -90, 80 in meters)
I have a perfectly round circle, which seems to correspond to EPSG:3785 projection.
I’m using GeometryCollectionShape for the shapes and then add them to Feature and then add that to InMemoryFeatureLayer
Is there a way to change default projection for WpfMap?
Is there some way to control the projection used for the shapes?
Thanks
Thomas
Thomas,
Sure, there is a way to control the projection both for the wpfMap and your shapes in the InMemoryFeatureLayer, please see the code snippet below that can meet your requirements exactly:
Any more questions please let me know,
wpfMap1.MapUnit = GeographyUnit.Meter;
// If want to know more srids, please refer Projections.rtf in Documentation folder.
ManagedProj4Projection proj4Projection = new ManagedProj4Projection();
proj4Projection.InternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(4326);
proj4Projection.ExternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(2163);
InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer();
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
inMemoryLayer.FeatureSource.Projection = proj4Projection;
Thanks,
Scott,
Scott,
Thanks.
I changed the code like this, otherwise it would not compile
manProj4Projection.InternalProjectionParameters= ManagedProj4Projection.GetEpsgParameters(4326);
manProj4Projection.ExternalProjectionParameters = ManagedProj4Projection.GetGoogleMapParameters();
..
inMemoryLayer = new InMemoryFeatureLayer();
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
inMemoryLayer.FeatureSource.Projection = manProj4Projection;
It seems to be trying to draw something because part of the background image where the circles are supposed to be are grey.
Any ideas?
Thanks
Thomas
I’ve been doing this for each shape and it has worked, but wanted to project a whole layer at one time to make it more efficient:
wpfMap1.MapUnit = GeographyUnit.Meter;
. . .
Proj4Projection proj4Projection = new Proj4Projection();
proj4Projection.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
proj4Projection.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
. . .
Vertex v2 = new Vertex();
proj4Projection.Open();
v2 = proj4Projection.ConvertToExternalProjection(long, lat);
proj4Projection.Close();
EllipseShape ellipse2 = new EllipseShape(new PointShape(v2.X,v2.Y ), 45000, 45000, GeographyUnit.Meter, DistanceUnit.Meter);
GeometryCollectionShape gcs = new GeometryCollectionShape();
gcs.Shapes.Add(ellipse2);
Feature feat1 = new Feature(gcs);
inMemoryLayer.InternalFeatures.Add(feat1);
layerOverlay.Layers.Add(inMemoryLayer);
wpfMap1.Overlays.Add(layerOverlay);
Hello,
I modified the projection example from 4.5 samples by adding some in memory layer and some graphics:
wpfMap1.MapUnit = GeographyUnit.Meter;
// If want to know more srids, please refer Projections.rtf in Documentation folder.
ManagedProj4Projection manProj4Projection = new ManagedProj4Projection();
manProj4Projection.InternalProjectionParameters = ManagedProj4Projection.GetEpsgParameters(4326);
manProj4Projection.ExternalProjectionParameters = ManagedProj4Projection.GetEpsgParameters(2163);
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Wpf Desktop Evaluation Edition 4.5\Samples\CSharp Samples\SampleData\Data\Countries02.shp");
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
worldLayer.FeatureSource.Projection = manProj4Projection;
worldLayer.Open();
wpfMap1.CurrentExtent = worldLayer.GetBoundingBox();
worldLayer.Close();
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.TileType = TileType.SingleTile;
staticOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)));
staticOverlay.Layers.Add("WorldLayer", worldLayer);
// now for some gfx
InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer();
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
inMemoryLayer.FeatureSource.Projection = manProj4Projection;
double lng = ..removed.. ,lat = ..removed..;
EllipseShape ellipse2 = new EllipseShape(new PointShape(lng, lat), 45000, 45000, GeographyUnit.Meter, DistanceUnit.Meter);
GeometryCollectionShape gcs = new GeometryCollectionShape();
gcs.Shapes.Add(ellipse2);
Feature feat1 = new Feature(gcs);
inMemoryLayer.InternalFeatures.Add(feat1);
staticOverlay.Layers.Add("gfxLayer", inMemoryLayer);
wpfMap1.Overlays.Add(staticOverlay);
wpfMap1.Refresh();
And now I got this:
“GeometryCollection is not supported now.” Exception on wpfMap1.Refresh();
If I comment out this line: inMemoryLayer.FeatureSource.Projection = manProj4Projection;
It executes, but the location is in the wrong place since it has not been reprojected
Any ideas?
Thanks
Thomas
Thomas,
I think you didin't use the latest version in your application, I tested your code and it worked fine, here is the code what I tested on my local machine below:
wpfMap1.MapUnit = GeographyUnit.Meter;
// If want to know more srids, please refer Projections.rtf in Documentation folder.
ManagedProj4Projection proj4Projection = new ManagedProj4Projection();
proj4Projection.InternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(4326);
proj4Projection.ExternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(2163);
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\Countries02.shp");
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
worldLayer.FeatureSource.Projection = proj4Projection;
worldLayer.Open();
wpfMap1.CurrentExtent = worldLayer.GetBoundingBox();
worldLayer.Close();
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.TileType = TileType.SingleTile;
staticOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)));
staticOverlay.Layers.Add("WorldLayer", worldLayer);
wpfMap1.Overlays.Add(staticOverlay);
InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer();
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.County2;
inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
inMemoryLayer.FeatureSource.Projection = proj4Projection;
double lng = 20000;
double lat = 20000;
EllipseShape ellipse2 = new EllipseShape(new PointShape(lng, lat), 45000, 45000, GeographyUnit.Meter, DistanceUnit.Meter);
GeometryCollectionShape gcs = new GeometryCollectionShape();
gcs.Shapes.Add(ellipse2);
Feature feat1 = new Feature(gcs);
inMemoryLayer.InternalFeatures.Add(feat1);
staticOverlay.Layers.Add("gfxLayer", inMemoryLayer);
wpfMap1.Overlays.Add(staticOverlay);
wpfMap1.Refresh();
The latest version number is 5.0.20.0, please get it from the DailyBuild of Development branch and try again,
Any more questions please let me know,
Thanks,
Scott,
Scott,
Thanks. I tired 5.0.0.0 just before and I get "Invalid is not supported now for projection."
I will look for 5.0.20.0, if you have a link handy please post it
thanks
Thomas
found it
Thomas,
I just checked the 5.0.20.0, it worked fine, there are not any exceptions occurred, if you still find out any problems please let me know,
Thanks,
Scott,
Scott,
Thanks, it runs but the ellipse becomes a huge weird Z-like shape across the western hemisphere?
Thomas
Scott,
I think I got it, have to draw in decimal degrees
double lng = -95.35;
double lat = 29.97;
EllipseShape ellipse2 = new EllipseShape(new PointShape(lng, lat), 45000, 45000, GeographyUnit.DecimalDegree, DistanceUnit.Meter);
many thanks for the help
Thomas
Thomas,
You are welcome, if you still have any problems please let me know,
Thanks,
Scott,
Scott,
It seems to behave erratically when I have more than layer (in addition to in memory layer). I will display once and then when I re-run it or zoom in or out the ellipses, line are gone.
I will try to isolate the issue and also try other daily builds
Take care
Thomas
Thomas,
Thanks for your question!
First you’d better to get the latest version to try again, the latest version number is 5.0.21.0, please get it from the DailyBuild of development branch, second if you always can reproduce this problem, please arrange a simple sample to us so that we can reproduce it properly and fix it as soon as we can,
Thanks,
Scott,
Scott,
Basically draw some graphics on "in memory layer" and then do a projection on that layer and it will not display:
. . .
EllipseShape ellipse2 = new EllipseShape(new PointShape(v), 50000, 50000, GeographyUnit.DecimalDegree, DistanceUnit.Meter);
GeometryCollectionShape gcs = new GeometryCollectionShape();
gcs.Shapes.Add(ellipse2);
Feature feat1 = new Feature(gcs);
inMemoryLayer.InternalFeatures.Add(feat1);
inMemoryLayer.FeatureSource.Projection = manProj4Projection;
. . .
It does not draw the graphics and covers up whatever is underneath.
Problem went away when I went to eval 5.0 and a daily build from around 6/6/11
I am now using full version of 5.0 and it has the above issue
Let me know if you can reproduce it, if not I will help more.
Going to full ver of 5.0 + latest daily build fixed this issue but introduces another which I think I will make another post about.
Take care
Thomas
Thomas,
Can you tell me which version did you use? The latest version number is 5.0.42.0 in the Development Dailybuild branch, if not, please get the latest one to take a try again, currently, I cannot reproduce your problem correctly, if you can arrange a sample to us what can reproduce this problem directly it is useful for us to fix your problem.
Thanks,
Scott,
Scott,
Yes, I used that version
I will try to make a sample
thanks
Thomas
Thomas,
Wait for your sample,
Thanks,
Scott,