ericnewton76/gmaps-api-net

ValueText uses incorrect types

Closed this issue · 6 comments

ValueText uses a string type for the Value property. Looking at the Google Maps docs, the response for value is some kind of number. This is corroborated by their own Javascript API documentation. Digging deeper, Google's Java client implementation exposes value as a Java long in both the Distance class and the Duration class. This is equivalent to an Int64 in C#.

So it seems like the definition of ValueText should be changed to:

public class ValueText
  {
    [JsonProperty("value")]
    public Int64 Value { get; set; }

    [JsonProperty("text")]
    public string Text { get; set; }

    public override string ToString()
    {
      return String.Format("{0} ({1})", Text, Value);
    }
}

Thanks for the heads up, @ZebraFlesh.

Because this would be technically an interface breaking change, maybe we do this prior to v1.0 ?

Okay, so I implemented this in commit 82a0bad. I'm wondering about since it was string before it could be empty, whereas now its a long and if the json data is empty, it'll have to use 0, which might be not correct.

I think it will be correct from Google's perspective, but might cause issues for consumers who made incorrect assumptions.

It's been a while since I've looked at this. Where is ValueText used? Is it just distance and duration representations, or does this class see wider usage?

Here's the code map image:
image

Basically used:

  • Direction API for DirectionLeg and DirectionStep
  • Distance Matrix for distance / duration

Thanks. That seems like using 0 would be correct (since it's all distance/duration).