Suppose I'm interested in the latitude of Los Angeles and I do the following:
In[1]:= c1 = CityData[{"LosAngeles", "California", "UnitedStates"}];
In[2]:= Latitude[c1]
Out[2]= Quantity[34.0194, "AngularDegrees"]
So the latitude is a Quantity! And if I get the string value I get:
In[4]:= ToString[Latitude[c1]]
Out[4]= "34.0194 degrees"
This seems a little at odds with the documentation where the examples seem to show a plain number being output.
Quantities are all well and good until I want to, say, use the Google Directions Api:
In[6]:= address =
ToString@StringForm[
"http://maps.googleapis.com/maps/api/directions/json?origin=`1`,`2`", Latitude[c1], Longitude[c1]]
Out[6]= "http://maps.googleapis.com/maps/api/directions/json?origin=34.0194 degrees,-118.411 degrees"
That's not at all what I want!
I suppose I can get the magnitude of the Quantity to get something more like what I want:
In[7]:= address =
ToString@StringForm[
"http://maps.googleapis.com/maps/api/directions/json?origin=`1`,`2`", QuantityMagnitude[Latitude[c1]], QuantityMagnitude[Longitude[c1]]]
Out[7]= "http://maps.googleapis.com/maps/api/directions/json?origin=34.0194,-118.411"
But that's beginning to feel like I'm straining and probably not doing it right. Is there a better way of dealing with these units?
Latitude[c1][[1]]andLongitude[c1][[1]]? – soandos Jan 01 '15 at 00:58QuantityMagnitude, for exampleQuantityMagnitude@Latitude[c1]. – C. E. Jan 01 '15 at 01:11SetSystemOptions["DataOptions" -> "ReturnQuantities" -> False]you can get back the old behaviour (trick from the 'Possible Issues' section ofDateDifference). – Sjoerd C. de Vries Jan 01 '15 at 13:10Out[12]= {"DataOptions" -> {"ReturnEntities" -> True, "ReturnQuantities" -> False, "UseDataWrappers" -> True}} In[13]:= Latitude[c1]
Out[13]= Quantity[34.0194, "AngularDegrees"]`. Maybe there isn't a better way?
– BigBaaadBob Jan 06 '15 at 03:58