Skip to content
This repository was archived by the owner on Nov 25, 2019. It is now read-only.

add SerializeToLonLat function and switch web calls to use that#71

Open
brnkhy wants to merge 1 commit intomasterfrom
serializetoLonLatFix
Open

add SerializeToLonLat function and switch web calls to use that#71
brnkhy wants to merge 1 commit intomasterfrom
serializetoLonLatFix

Conversation

@brnkhy
Copy link
Copy Markdown
Collaborator

@brnkhy brnkhy commented May 2, 2017

change ToString back to its default behaviour

change ToString back to its default behaviour
@brnkhy brnkhy requested a review from david-rhodes May 2, 2017 18:32
@david-rhodes
Copy link
Copy Markdown
Contributor

Well, this is awkward. I found out why I had to override ToString with longitude as the first component (x). If you check Drive.unity, you will get a NullReferenceException caused by the directions request. This is because deep down in the url formatting for directions waypoints is this:

protected static string GetUrlQueryFromArray<U>(U[] items, string separator = ",")
{
	return string.Join(separator, items.Select(item => item.ToString()).ToArray());
}

This is using ToString() rather than SerializeToLonLat(). It was hard to find this because of the generic usage here.

Not sure if this is an easy fix or even worth it.

@david-rhodes
Copy link
Copy Markdown
Contributor

I'd also like to note that if feels "dangerous" to expect ToString to format for URL requests specifically, as ToString is also often used for lots of other things.

@wilhelmberg
Copy link
Copy Markdown
Contributor

Reminder: please don't forget about unit tests, either run them locally or check on AppVeyor.
P.S.: check the branch build as the PR build is expected to always fail on AppVeyor. This is a security feature as encrypted environment variables are not decrypted for PRs.

eg.:
https://ci.appveyor.com/project/Mapbox/mapbox-sdk-unity-core/build/1.0.332/job/8djpnr40f6xbnb1h/tests
image


This is using ToString() rather than SerializeToLonLat(). It was hard to find this because of the generic usage here.

I'd also like to note that if feels "dangerous" to expect ToString to format for URL requests specifically, as ToString is also often used for lots of other things.

What about about dedicated methods for each use case?

  • ToUrlString()
  • SerializeToLonLat()
  • ...

@david-rhodes
Copy link
Copy Markdown
Contributor

What about about dedicated methods for each use case?

This is probably fine, but will require sweeping changes, with many classes affected, right?

@wilhelmberg
Copy link
Copy Markdown
Contributor

@brnkhy do you still want to get this in before we freeze or is this PR stale?

@brnkhy
Copy link
Copy Markdown
Collaborator Author

brnkhy commented May 15, 2017

@BergWerkGIS I think we should, I feel like overriding ToString like that is fundamentally wrong so if you guys agree, let's not ship like that.

@wilhelmberg
Copy link
Copy Markdown
Contributor

@brnkhy I, too, like methods to be as verbose as possible (and needed).

So how about SerializeToLonLat() and for the sake of completeness also SerializeToLatLon()?

And let ToString() return something like

string.Format(NumberFormatInfo.InvariantInfo, "X:{0:F5} Y:{1:F5}", this.x, this.y);

which would have the advantage to show up nicely in the debugger.

Also: please evaluate the consequence of this change in mapbox-unity-sdk (see above) and queue up a PR there that takes care of needed changes.

@brnkhy
Copy link
Copy Markdown
Collaborator Author

brnkhy commented May 15, 2017

@BergWerkGIS SerializeToLonLat is already there we can add SerializeToLatLon as well, it's not used anywhere but maybe just for completeness as you said.
I think I would prefer to keep ToString in original format even though adding x/y labels like that won't change behaviour. ToUrlString is a closed term as well.
please evaluate the consequence of this change
you mean the tests? I'll check them 👍

@wilhelmberg
Copy link
Copy Markdown
Contributor

I think I would prefer to keep ToString in original format even though adding x/y labels like that won't change behaviour. ToUrlString is a closed term as well.
please evaluate the consequence of this change
you mean the tests? I'll check them 👍

Yes, tests in this repo (see above).

But as well the consequences of this PR in mapbox-unity-sdk as mentioned by @david-rhodes, eg the Drive example (see above).
I think we are going to need a PR in mapbox-unity-sdk as well, no?

@david-rhodes
Copy link
Copy Markdown
Contributor

@BergWerkGIS @brnkhy As mentioned here: #71 (comment), I think this refactor is more work than we think. GetUrlQueryFromArray is used by multiple objects--not just directions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants