I've been using the HERE Java library to decode binary TPEG files, however I am running into trouble when trying to get locations from the TMC location reference.
I'd like to be able to take the TMC reference (location id, country code, location table version) and get lat/long coordinates. Unfortunately, after pouring through HERE's API docs, I can't seem to find an API that would do this for me.
Once you have a TMCLocationReference, you can transform it to a LinearLocation using LocationReferenceResolvers.tmc method.
There should be an example in Resolving a Location Reference section.
The resolver allows you to transform the TMCLocationReference into a LinearLocation containing internal HERE maps ids, which can be transformed to WKT like LineStrings using for instance the PropertyMaps.geometry method, for which you can find more details in the dev guide.
As an example, you could do something like this:
StandaloneCatalogFactory scf = new StandaloneCatalogFactory();
Catalog optimizedMap = scf.create(OptimizedMap.v2.HRN);
CacheManager cacheManager = CacheManager.withLruCache();
LocationReferenceResolver<TMCLocationReference, BidirectionalLinearLocation> tmcResolver =
LocationReferenceResolvers.tmc(optimizedMap, cacheManager);
TMCLocationReference tmcLocationReference = ...
BidirectionalLinearLocation linearLocation = tmcResolver.resolve(tmcLocationReference);
PropertyMap<Vertex, LineStringHolder<GeoCoordinate>> geometry =
PropertyMaps.geometry(optimizedMap, cacheManager);
LineStringHolder<GeoCoordinate> lineString =
geometry.get(linearLocation.getLocation().getPath().get(0));
Related
I am looking for a solution using Maven and Java (Not Spring) where I can upload all my Key and labels and flag value by Json to deploy.
When I configure my project in Jenkins it should apply all the values which are changed.
Kindly provide me some directions, I tried lot with less material on this topic
I managed to workout the solution. Basically following this Microsoft Azure Link
, but not completely solved my problem by this link though. Below is the Code Snippet which solved my problem. Code is not testable or productionable , this is just for reference.
public void process() {
String value = "{\"id\": \"test\", \"description\": \"Sample Feature\",\"enabled\": false,\"conditions\": { \"client_filters\": []}}";
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
ConfigurationClient configurationClient = new ConfigurationClientBuilder()
.connectionString(END_POINT)
.buildClient();
final ConfigurationSetting configurationSetting = new ConfigurationSetting();
configurationSetting.setKey(format(".appconfig.abc/%s", "abc"));
configurationSetting.setLabel("lable");
configurationSetting.setContentType("application/vnd.microsoft.appconfig.ff+json;charset=utf-8");
configurationSetting.setValue(value);
configurationClient.addConfigurationSettingWithResponse(configurationSetting, NONE)
}
Key points here is ".appconfig.abc" , At this point of time we don't have direct call to Feature Management , but we can add Key and labels to configuration as I said in the code snippet but with the Key as ".appconfig.abc" which you can get this info from portal. And the value should be a Json object, how we make this Json is upto you really.
Overall so much of information around the sites but none of them are connected in Java world for Azure. May be helpful to any one.
End Point , one can get from the Configuration Access Keys.
Geonames database works fine for me when to query via WEB. However, there are java packages org.geonames with classes WebService, Toponym and other ones, which seem to do the same from within java application. So, I try to use org.geonames for creating a query like
https://secure.geonames.org/countrySubdivision?lat=47.03&lng=30.2&username=myUserName
which, when sending via WEB, returns xml nwith countryName and adminName1 tags. However, I cannot find appropriate method (methods) in org.geonames returning object with countryName and adminName1 by given latitude and longitude.
How do I solve the problem?
The methods are in the class Toponym, not in the package.
Here is the javadoc with all the methods.
And here is an example from their website.
WebService.setUserName("demo"); // add your username here
ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();
searchCriteria.setQ("zurich");
ToponymSearchResult searchResult = WebService.search(searchCriteria);
for (Toponym toponym : searchResult.getToponyms()) {
System.out.println(toponym.getName()+" "+ toponym.getCountryName());
}
I am using the Tensorflow Java Api to load an already created Tensorflow model into the JVM.
I am using this as an example: tensorflow/examples/LabelImage.java
Here is my simple scala code:
import java.nio.file.{Files, Path, Paths}
import org.tensorflow.{Graph, Session, Tensor}
def readAllBytesOrExit(path: Path): Array[Byte] = Files.readAllBytes(path)
val graphDef = readAllBytesOrExit(Paths.get("PATH_TO_A_SINGLE_FILE_DESCRIBING_TF_MODEL.pb"))
val g = new Graph()
g.importGraphDef(graphDef)
val session = new Session(g)
val result: Tensor = session.runner().feed("input", image).fetch("output").run().get(0))
How do I save my model to get both the Session and the Graph stored in the same file. as described in the "PATH_TO_A_SINGLE_FILE_DESCRIBING_TF_MODEL.pb" above.
Described here it mentions:
The serialized representation of the graph, often referred to as a
GraphDef, can be generated by toGraphDef() and equivalents in other
language APIs.
What are the equivalents in other language APIs? I dont find it obvious
Note: I already looked at the mnist_saved_model.py under tensorflow_serving but saving it through that procedure gives me a .pb file and a variables folder. When trying to load that .pb file I get: java.lang.IllegalArgumentException: Invalid GraphDef
Currently with the Java API of tensorflow, I only found how to save a graph as a graphDef (i.e. without its variables and meta-data). This can be done by just writing the Array[Byte] to a file:
Files.write(Paths.get(modelDir, modelName), myGraph.toGraphDef)
Here myGraph is a java object from the Graph class.
I would suggest to save your model from the Python API, using the SavedModel api defined here. It will save your model in a folder with both the serialized graph in a .pb file and the variables in a folder. Note the tag_constants you use as you'll need it in your scala/java code to load the model with the variables. Then the graph and session with variables are easily loaded with the SavedModelBundle java class from the java api. It returns you a wrapper with both the graph and the session containing the variables values:
val model = SavedModelBundle.load(modelDir, modelTag)
If you already tried this, maybe you can share your code to see why it returned an invalid GraphDef.
Another option is to freeze your graph, i.e. you turned your variable nodes into constant Nodes so everything is self-contained in the .pb file. Mores infos here for the freezing part
I have a lot of geo data stored online with latitude and longitude and I'd like to use the distanceTo method instead of my own haversine formula.
So I need to put each record into a Location field, but here's my question: it requires a "provider" string. Why? What will Android do with that information?
for (ArrayList<String> item : Places_Data) {
Location itemloc = new Location("provider");
itemloc.setLatitude(latIn);
itemloc.setLongitude(lonIn);
//do something with my new location
}
From the source code for Location, it doesn't use the string to do anything meaningful. It just uses it to describe the Location internally. If you do Location#toString(), it prints out the co-ordinates, the provider and other details (accuracy, etc). That's all it's used for, internal description.
You can make the provider anything, as seen in this answer: Creating Android Location Object
Use correctly the way
package android.location.LocationManager
Location location = new Location(LocationManager.GPS_PROVIDER);
Use NETWORK_PROVIDER o GPS_PROVIDER
https://developer.android.com/reference/android/location/LocationManager.html#GPS_PROVIDER
https://developer.android.com/reference/android/location/LocationManager.html#NETWORK_PROVIDER
I am trying to call some web services written in Java from my asp.net code. I don't know Java.
There are several methods each with multiple properties. These methods are then passed to one controlling method. The problem occurs with how to handle arrays. I cannot seem to get the syntax quite right.
For example, there can be from 1 to n locations. Each location has multiple properties.
I can build one location ok. But how do I build an array of locations? I tried several approaches. Here is the closest I’ve gotten. It complies but crashes on the third to the last line below. I’ve removed the code that is not relevant to explaining the problem.
The error says: Object reference not set to an instance of an object.
WebReferenceMERegistration.getMERegistration _myMERegistration =
new WebReferenceMERegistration.getMERegistration();
WebReferenceMERegistration.Locations _myLocation =
new WebReferenceMERegistration.Locations();
WebReferenceMERegistration.Locations[] _myLocations = null;
_myLocation.AddressLine1 = txtEmployerAddress1.Text;
_myLocation.AddressLine2 = txtEmployerAddress2.Text;
// more properties set here
_myLocations[0] = _myLocation;
_myMERegistration.Locations = _myLocations;
_Results = _myRegistrationService.getMERegistration(_myMERegistration);
int length = ...;
WebReferenceMERegistration.Locations[] _myLocations =
new WebReferenceMERegistration.Locations[length];