cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How set locatoin deviation?

How set locatoin deviation?

can i make this capture ussing subscription?

cause i use add value stream entry

so, doesn't work property alert

then, i want make this alert in subscription

Or could help me set the radius around with longitude and latitude

if i want  set surrounding radius value {35.xxxx,127.xxxx }around 1km

and i want change 35.xxxx,127.xxxx -> address

plz help me hehehe

10 REPLIES 10

Re: How set locatoin deviation?

Hi Seonho, sorry I may not have fully understood your requirement, are you looking to create GeoFence with your data? something like this

Re: How set locatoin deviation?

No

i want get address value base on longitude,latetude

if i got 39.773844,-89.643711 . i get USA Illinois Springfield base on that value

thanks

i don't need geoFence yet

Re: How set locatoin deviation?

Dear seonho Cha,

One solution I could imagine is to customize an extension of your own.

In the Java Extension you could utilize the Google open API to get Address inforamtion based on a Location.

Sample code like this:

@ThingworxServiceDefinition( name="GetAddressFromLocation", description="get address from a location" )
@ThingworxServiceResult( name="Result", description="Result", baseType="STRING" )
public String GetAddressFromLocation(
   @ThingworxServiceParameter( name="longitude", description="", baseType="NUMBER" ) Double longitude,
   @ThingworxServiceParameter( name="latitude", description="", baseType="NUMBER" ) Double latitude
   ) throws Exception {

  String address = GetLocationMsg(latitude,longitude);
  return address;
}

public static String GetLocationMsg(double latitude,double longitude){

  String message = "";
          String url = String.format(
              "http://maps.google.cn/maps/api/geocode/json?latlng=%s,%s&language=CN",
              latitude,longitude);
          URL myURL = null;
          URLConnection httpsConn = null;
          try {
              myURL = new URL(url);
          } catch (MalformedURLException e) {
            e.printStackTrace();
          }
          try {
              httpsConn = (URLConnection) myURL.openConnection();
              if (httpsConn != null) {
                  InputStreamReader insr = new InputStreamReader(
                          httpsConn.getInputStream(), "UTF-8");
                  BufferedReader br = new BufferedReader(insr);
                  String data = null;
                  while ((data = br.readLine()) != null) {
                  message = message+data;
                  }
                  insr.close();
              }
          } catch (IOException e) {
              e.printStackTrace();
          }
  return message;
  }

This will return a JSON address message, you could then parse this JSON file for the exact address you want.

Thanks,

Br,

Anna

Re: How set locatoin deviation?

i don't know how to use geocoder, and json...

could you please help me ..?

if you know, how i can use geocoder?

i want use reverse geocoder

thanks,

Re: How set locatoin deviation?

Dear Seohno Cha,

Firstly you could create a service in Thingworx composer, say, getAddString Service.

Then you could code in the Service like:

//var url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=39.773844,-89.643711";

var url = "http://maps.googleapis.com/maps/api/geocode/json?latlng="+latitude+","+longitude;

var params = {

  proxyScheme: undefined /* STRING */,

  headers: undefined /* JSON */,

  ignoreSSLErrors: undefined /* BOOLEAN */,

  useNTLM: undefined /* BOOLEAN */,

  workstation: undefined /* STRING */,

  useProxy: undefined/* BOOLEAN */,

  withCookies: undefined /* BOOLEAN */,

  proxyHost: undefined/* STRING */,

  url: url /* STRING */,

  timeout: undefined /* NUMBER */,

  proxyPort: undefined/* INTEGER */,

  password: undefined /* STRING */,

  domain: undefined /* STRING */,

  username: undefined /* STRING */

};

var json1 = Resources["ContentLoaderFunctions"].GetJSON(params);

var result = json1.results[0].formatted_address;

input:

latitude:NUMBER

longitude:NUMBER

output: STRING   

Hope this helps,

Br,

Anna

Re: How set locatoin deviation?

it's really helpful

i'm sorry to late comment

cause i had some problem..

that was error

still yesterday it was great

but now

... How to fix it?

can you help me please..?

Re: How set locatoin deviation?

Dear seonho cha,

What's the difference between your visiting ThingWorx the last time it was working fine and the last time it was not working fine(got the error you attached above)? For example, did you use https://<IP>:<PORT>/Thingworx/Composer to access thingworx when it failed? do you visit with unsecure visit like http://<IP>:<PORT>/Thingworx/Composer to visit Thingworx when it succeeded to execute GetJSON?

Or, did you use a different JDK to run ThingWorx between the two tests?

What's the OS you are running ThingWorx instance? Linux or Windows?

From the error, I googled it:Unable to Access SSL Services due to java.security.InvalidAlgorithmParameterException - Atlassian Do...

It looks like The JVM cannot find the javax.net.ssl.trustStore required for SSL, or it does not contain the required certificates.

Please check your environment and have one more test today and let me know of your test result.

please also take reference to this disucussion: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty on Li...

Thanks,

Br,

Anna

Re: How set locatoin deviation?

Dear seonho cha,

Please use HTTP instead of HTTPS which will verify SSL connection.

It works on my side with the url:

var url = "http://maps.googleapis.com/maps/api/geocode/json?latlng="+latitude+","+longitude;

Re: How set locatoin deviation?

thanks your kind!!

you're angel!! really thanks