Question
virtusa
IN
Last activity: 23 Aug 2016 7:52 EDT
service for implementing distance between places
i have req in my project that i have two places for example hyderabad(india) and banglore(india) when we enter the location names in the text inputs which will give the distance b/w the places using some external services like google maps or using some other services so can u plz suggest me how can we do this
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
PEG
IN
Do you want to connect to external service using PRPC ? or do you want create a service which gives distance of two places using location ?
virtusa
IN
i need to create a service for doing that thing even use the service in my prpc application
Pegasystems Inc.
US
This answer made things a little less clear for me.
To clarify the question from Gangababu, what things on this list will users of your application need to do?:
- use the application within a web browser / phone app and enter the parameters, then see a result in the UI
- call a new Service that will exist on your Pega system, which they will use to get the data using client software of some sort
I think you are talking about # 1.
In that case, you will need to use a Connector feature such as Connect REST, and call the remote API of your choice in order to get the data for use in your application logic.
In Pega 7 you may use a Wizard (Designer Studio Button -> Integration-> New REST Integration) to quickly and easily generate the artifacts you need.
Please share the version of Pega that you are using to help people accurately answer your question.
Now the question is, do you want to create this service in PRPC? Or you want to use JAX-WS/RS/ Apache-CXF framework to do it from an external service running on your application server? Nevertheless look into Google map API which returns data in JSON using REST:
Distance Matrix Service | Google Maps JavaScript API | Google Developers
Pegasystems Inc.
US
If you want to calculate the distance in PRPC and not have to depend on external service provider to do the calculation, you can use the latitude and longitude of the locations to plug into the Haversine formula (Haversine formula - Wikipedia, the free encyclopedia) to calculate distance. The Haversine formula does not take into account that the earth is a slightly squashed sphere, but there are formulas that do if you need the extra accuracy.
virtusa
IN
i am using 7.1.6 version
virtusa
IN
i want to create a service using java using some java-rs serviceand i want to use it in my prpc how can do that???
PEG
IN
You can use PRPC as Connector either Connect-REST or Connect-SOAP depends on your service.
virtusa
IN
ya that is gud but can u post me the logic of service activity how to caluculate distance b/w two places
Hi Prashanth,
You want to begin with taking the Integration course with Pega academy. That will give you a solid background on integrating 3rd party services with Pega and similarly developing services in Pega.
Regards,
Adi
Coforge
IN
You can find demo http://jsfiddle.net/XRMxf/ here.
Use non autogenerated and try to do like this.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var origin = "Hyderabad",
destination = "Banglore",
service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [origin],
destinations: [destination],
travelMode: google.maps.TravelMode.DRIVING,
avoidHighways: false,
avoidTolls: false
},
callback
);
function callback(response, status) {
var orig = document.getElementById("orig"),
dest = document.getElementById("dest"),
dist = document.getElementById("dist");
You can find demo http://jsfiddle.net/XRMxf/ here.
Use non autogenerated and try to do like this.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var origin = "Hyderabad",
destination = "Banglore",
service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [origin],
destinations: [destination],
travelMode: google.maps.TravelMode.DRIVING,
avoidHighways: false,
avoidTolls: false
},
callback
);
function callback(response, status) {
var orig = document.getElementById("orig"),
dest = document.getElementById("dest"),
dist = document.getElementById("dist");
if(status=="OK") {
orig.value = response.destinationAddresses[0];
dest.value = response.originAddresses[0];
dist.value = response.rows[0].elements[0].distance.text;
} else {
alert("Error: " + status);
}
}
</script>
</head>
<body>
<br>
Google Distance Matrix.<br><br>
Origin: <input id="dest" type="text" style="width:35em"><br><br>
Destination: <input id="orig" type="text" style="width:35em"><br><br>
Distance (by car): <input id="dist" type="text" style="width:35em">
</body>
</html>