10 Replies Latest reply on Apr 24, 2017 9:51 PM by anna RSS
    scha-2 Explorer

    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

      • Re: How set locatoin deviation?
        supandey Collaborator

        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?
            scha-2 Explorer

            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?
                anna Creator

                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