Usage of System.Windows.Point

Jan 2, 2010 at 5:32 AM
Edited Jan 2, 2010 at 7:50 AM

I think it was mistake to use System.Windows.Point structure for Latitude/Longitude operations in MapControl.

The problem is that Point does not serialize properly (or something) and it is not possible to use it over WebServices (for example WCF).

So if I do have Point[] on the server side - I can not send it to the client side and use it straight away.

Also Point has X and Y, so it is a bit confusing - it should be Latitude and Longitude.

I think it would be much better to introduce some serializable, webservice friendly Point class with Latitude and Longitude and use that everywhere...

What do you think guys?

Developer
Jan 2, 2010 at 9:58 AM
Have you tried attach [Serializable] in your datacontract? http://forums.silverlight.net/forums/p/26577/90890.aspx

From: [email removed]
Sent: Saturday, January 02, 2010 6:32 AM
To: [email removed]
Subject: Usage of System.Windows.Point [deepearth:79535]

From: alenas

I think it was mistake to use System.Windows.Point structure for operations in MapControl.

The problem is that Point does not serialize properly (or something) and it is not possible to use it over WebServices (for example WCF).

So if I do have ObservableCollection<Point> on the server side - I can not send it to the client side and use it straight away.

Also Point has X and Y, so it is a bit confusing - it should be Latitude and Longitude.

I think it would be much better to introduce some serializable, webservice friendly Point class with Latitude and Longitude and use that everywhere...

That's what I will have to do for my project - so if you think that makes sense - I could send back changes to you guys...

What do you think guys?

Jan 2, 2010 at 10:07 AM

Same as in the link you gave above:

What I get on the Silverlight client proxy is a custom class which has fields like _x and _y, but no properties like X and Y.

And you can not populate the struct with _x and _y - you need X and Y. So seems like it is not possible to put it into System.Windows.Point structure.

If I use custom class, then I have to do conversion to Point again. That does not make sense. Better to use proper class on both ends.

Developer
Jan 2, 2010 at 11:16 AM
OK, another idea is to expose either ICoordinate or IPoint from GEOAPI in combination with NetTopology Suite. GEOAPI is really would I would go for since it follows OGC. But I don't know if that is meaningful for you. Please let me know if you implement this and how GEOAPI and NetTopologySuite works with WCF.

From: [email removed]
Sent: Saturday, January 02, 2010 11:07 AM
To: [email removed]
Subject: Re: Usage of System.Windows.Point [deepearth:79535]

From: alenas

Same as in the link you gave above:

What I get on the Silverlight client proxy is a custom class which has fields like _x and _y, but no properties like X and Y.

And you can not populate the struct with _x and _y - you need X and Y. So seems like it is not possible to put it into System.Windows.Point structure.

If I use custom class, then I have to do conversion to Point again. That does not make sense. Better to use proper class on both ends.

Jan 3, 2010 at 8:26 AM

Yep, I think ICoordinate from GeoAPI will work well in this case. Will try today and will let you know...

Jan 3, 2010 at 1:32 PM

I still do not get why in GEOAPI and NetTopology Suite - are using X, Y, Z instead of Longitude, Latitude, Altitude

This suppose to be GEO position (or coordinate) and I am sure the standard is latitude, longitude and not confusing x, y (I bet many people would put latitude in x).

Any explanation?

Jan 3, 2010 at 7:59 PM

I uploaded patch with changes that I did - though I did not do enough testing and not sure if collections are better one way or another.

Going on holiday for a week - so will be able to take a look later. See if this makes sense to you guys. But I would still prefer Latitude, Longitude instead of Y, X...

Feb 2, 2010 at 10:37 PM

Uploaded another patch.

This time I made proper interface ICoordinate and class Coordinate in DeepEarth.Common. Then refactored DeepEarth.Client.MapControl to use ICoordinate for geographic coordinate.

Also made generic classes for PointBase<ICoordinate>, LineString<>, Polygon<>.

This way I can have my own class that inherits from ICoordinate. I can send that collection over webservice and without conversion put it straight to the new polygon (for example).

Also extracted shape Update methods from GeometryLayer to PointBase and PathBase - should be easier to create new shapes (like circle).

I think this is definitely better than was before. I do not need to convert anything when transfering my data from db, through webservices to the point where it is being shown on the map.

Seems like all the code is working - example site, etc...Tell me what you think...

Coordinator
Feb 3, 2010 at 3:36 AM

I agree that Lat,Long, Alt is much nicer. I think the generic XYZ is common for other projection formats and GeoAPI supports these.

I'm making some changes to the toolkit right now (checked in shortly) and will take a look.

Thanks for taking the time to make the patch, we're all keen to enhance the control here and every bit helps.

Oct 18, 2010 at 10:03 PM
Edited Oct 18, 2010 at 10:05 PM

Hi there !

I am a beginner with DE. Trying to apply the Bings map Toolkit into my project but I found something that make me confused for lots of time so far. Esp. with the XY coordinate. I would like to know how to use those sample data in Lat Lon. Is there any ways to convert between the XYZ and Lat Lon, Alt ? ..confusing... please help me to understand these.

Thanks a lot,

middlevn

 

Oct 18, 2010 at 10:28 PM

Hi,

You do not need to convert from latitude, longitude to XYZ.

X is Longitude, Y is Latitude and Z is altitude in DE. Also if  you apply my patch to your subversion repository - then you can use ICoordinate and have proper Latitude and Longitude instead of confusing XYZ. Though not sure if my patch works with the latest DE versions...

Oct 19, 2010 at 9:24 PM
alenas wrote:

Hi,

You do not need to convert from latitude, longitude to XYZ.

X is Longitude, Y is Latitude and Z is altitude in DE. Also if  you apply my patch to your subversion repository - then you can use ICoordinate and have proper Latitude and Longitude instead of confusing XYZ. Though not sure if my patch works with the latest DE versions...

Hi alenas,

I sounds a little complicated for me to let an Bing Toolkit example to work with Lat,lon data. To make it simpler, is there a way to convert Lat, Lon into XYZ then use it just like it is so far? you guy knows, I am not using subversion so do not know how to apply you patch.

Thanks. 

Oct 19, 2010 at 11:13 PM

so when you need to pass coordinates to some object - you use System.Point

for example (don't have actual DE code here):

point.Point = new Point(Longitude, Latitude)

notice that x is longitude and goes as first argument

tell me if you still have trouble and which demo class you are looking at - then i can send you code from DE sample later

Oct 20, 2010 at 6:05 AM

Thanks alenas a lot. It works now.