• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by OJ3D · Nov 13, 2015 at 09:50 PM · networkingjsonapidictionaryurl schemes

Yelp API- Latitude/Longitude parameter problem {Key/Value}

Hey guys, I have an issue that I can't quite figure out. Seems straightforward especially considering the script I compiled works smoothly. I collaborated and updated the yelp script that I posted on GitHub link text

Anyway, the yelp console indicates passing double values if I want to use latitude,longitude search method. For example, San Francisco's latitude/longitude is: 37.788022,-122.399797 . To pass this you'd have to use the "ll" key and then set the value like the example code indicates below{"ll",latitude_value,Longitude_value}:

 public static string searchterm = "food";
 public static string searchlocation = "San Francisco"+","+"Ca";
 public static double latitude = 37.788022;  //San Fran
 public static double longitude = -122.399797;
 public static string Coordinates = latitude + "," + longitude;
     .......
 // Fix up hashes to be webfriendly
     searchLocation = Uri.EscapeDataString(searchLocation);

     SortedDictionary<string, string> YelpParamsDictionary = new SortedDictionary<string, string> ()
     {
         {"term", searchterm },
      // {"location",searchlocation } 
         {"ll", Coordinates }            //<-------Here's the lat/long key/value paramter
     };

     WWW query = CreateYelpAPIQuery (YelpURL2,YelpParamsDictionary);
     yield return query;
      .......
      ........

Anyway, I recieved the JSON string when I use location method {"location","San Francisco"} with no problems. But when I switch to using their latitude/longitude method it gives me a bad request. No clue why. I have even tried converting the values to strings. Here's yelps api console - link text

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Nov 14, 2015 at 04:44 AM

Just a shot in the dark: What's your nationality? Because some countries use a comma as decimal point. Since double/float to string conversion uses the systems culture settings your lat long string might look like this:

 "37,788022,-122,399797"

instead of

 "37.788022,-122.399797"

Of course that format most likely isn't recognised. You should make sure to use a culture neutral conversion. Using the Invariant culture is usually the best approach when converting numbers to string.


If that's not the problem, make sure your Decimal Degrees lat / lon format is actually accepted by the site. There are a lot of different ways you can write down lat/lon coordinates.

edit
Ok. Since you took that example from the API documentation they should accept decimal Degrees ^^. So it's probably the to string conversion. You can check this easily be printing out all your parameters before you make that request.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by OJ3D · Nov 15, 2015 at 09:57 AM

Bunny83 - thanks for getting back to me. I really appreciate it. I tried your method, and unfortunately didn't get any traction.

 public static string latitude = "38.882071";  //washington dc
 public static string longitude = "-77.111845";
 public static string Coordinates =  latitude.ToString (CultureInfo.CreateSpecificCulture ("de-DE")) + "," + longitude.ToString (CultureInfo.CreateSpecificCulture ("de-DE"));
 //Coordinates  = 38,882071,-77,111845
     
         {"ll", Coordinates} //gives me errors

I Got similar errors. :(. FYI-I'm american,from DC. I don't get why the parameter is being so sensitive, I'm completely baffled. I moved to using the zip code method until it can get figured out- that key/value pair is:

 public static string zipcode= "22209";
  {"location",zipcode}

I get a response back,which is good. This kind of get's me there, but the center/reference point of a zip code can be totally different from a specific location(zip-lat/long vs. a specific location-lat/long). A zipcode is area-based which means it could cover a a lot of ground or not.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multi-threading safely 1 Answer

UnirtyWebRequest.Post sending empty uploadHanlder.data 1 Answer

How do I send data to a cloud server like Amazon EC2? 1 Answer

HTTP Requests removed on Android Pie (API 28+) 2 Answers

deserialize a json web api on top of the class or inside the start function 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges