Is it possible to get the placeCategory id of a place? (iOS Here SDK Explore Edition) - here-api

I want to use the category id of the place described here: https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics-places/places-category-system-full.html.
How can i get it? Via the searchEngine?
I tried:
if !places.isEmpty {
for place in places {
let placeIdQuery = PlaceIdQuery(place.id)
searchEngine.search(placeIdQuery: placeIdQuery, languageCode: .deDe, completion: onFollowUpSearchCompleted)
}
}
But i only get the same places.

Found it.
Every Place has the optional details -> category.

Related

Is there a way to loop dynamic links parameters to avoid repetition of values?

I'm using kotlin and I have implemented dynamic links to my app, and when ever the user clicks the link, it will retrieve specific data from Firebase depending on the link. I try to query the parameters of the link but I was unsuccessful so I had to get creative and use .endWith("") statement to assign each link a specific collection from Firebase. The problem is that the more links I use, the bigger the list will get and is not convinient for me. I know there has to be a more efficient way. Any suggestions? Thanks in advance.
val drinksCoffeeShopsFB = FirebaseFirestore.getInstance().collection("Drinks").document("CoffeeShops")
val foodFastFoodFB = FirebaseFirestore.getInstance().collection("Food").document("FastFood")
var deepLink: Uri? = null
val it = Firebase.dynamicLinks.getDynamicLink(intent).result
if (it != null) { deepLink = it.link }
when{
deepLink.toString().endsWith("DrinksCoffeeShops/1/")-> {drinksCoffeeShopsFB.collection("1").get()}
deepLink.toString().endsWith("DrinksCoffeeShops/2/")-> {drinksCoffeeShopsFB.collection("2").get()}
deepLink.toString().endsWith("DrinksCoffeeShops/3/")-> {drinksCoffeeShopsFB.collection("3").get()}
deepLink.toString().endsWith("DrinksCoffeeShops/4/")-> {drinksCoffeeShopsFB.collection("4").get()}
deepLink.toString().endsWith("DrinksCoffeeShops/5/")-> {drinksCoffeeShopsFB.collection("5").get()}
deepLink.toString().endsWith("DrinksCoffeeShops/6/")-> {drinksCoffeeShopsFB.collection("6").get()}
...
deepLink.toString().endsWith("FoodFastFood/1/")-> {foodFastFoodFB.collection("1").get()}
deepLink.toString().endsWith("FoodFastFood/2/")-> {foodFastFoodFB.collection("2").get()}
deepLink.toString().endsWith("FoodFastFood/3/")-> {foodFastFoodFB.collection("3").get()}
deepLink.toString().endsWith("FoodFastFood/4/")-> {foodFastFoodFB.collection("4").get()}
deepLink.toString().endsWith("FoodFastFood/5/")-> {foodFastFoodFB.collection("5").get()}
deepLink.toString().endsWith("FoodFastFood/6/")-> {foodFastFoodFB.collection("6").get()}
...
}
This is an example of the dynamic link being used to retrieve its parameters
https://myapp.page.link/DrinksCoffeeShops/2/
You can try something like this:
val id = link.removeSuffix("/").split('/').last() // This will give you the id present in the deepLink
if("DrinksCoffeeShops" in link)
drinksCoffeeShopsFB.collection(id).get()
if("FoodFastFood" in link)
foodFastFoodFB.collection(id).get()

iOS WatchOS5 how to customize title in GraphicRectangular complication?

I want to remove text from my graphic rectangular complication, or set it to empty string. By default it is the app name. I tried to set display name to " " within watchKit plist file, but that did not seem to change it.
How do I remove text from my graphic rectangular WatchOS5 complication?
I see that there's some way to get (assign?) a CLKTextProvider as described here: https://developer.apple.com/documentation/clockkit/clktextprovider However, it seems to involve adding a localizable strings file and I don't want to mess with this if there's an easier way to get image only for the CLKComplicationTemplateGraphicRectangularLargeImage
func getLocalizableSampleTemplate(for complication: CLKComplication, withHandler handler: #escaping (CLKComplicationTemplate?) -> Void) {
// This method will be called once per supported complication, and the results will be cached
if complication.family == .graphicRectangular {
let template = GraphicTemplate()
template.textProvider = CLKSimpleTextProvider.init(text: "")
handler(template)
}else {
handler(nil)
}
}
class GraphicTemplate: CLKComplicationTemplateGraphicRectangularLargeImage {
}
You don't need to mess with localizable strings (phew).
There are two places you'll need to set up the appearance of the complication.
The sample template - this is displayed to the user as they're customizing a face and scrolling through the list of available complications. You provide this sample in the getLocalizableSample(for: withHandler:) method per family of complication, as you show in your question.
The actual live complication shown on the face, which you provide in the getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: #escaping (CLKComplicationTimelineEntry?) -> Void) method of the CLKComplicationDataSource.
In both places you'll need to return the template with a text provider (you'll crash on runtime if not), although it's fine to return an empty string. This should remove the app name.
let template = CLKComplicationTemplateGraphicRectangularLargeImage()
template.textProvider = CLKSimpleTextProvider.init(text: "")
template.imageProvider = CLKFullColorImageProvider(fullColorImage: myImage)
return template
(By the way, have you seen the recent Apple Tech Talk about complications for watch os5? It's a good one 😄).

Filter posts by custom fields

I want to give users the ability to sort posts themselves using some filter links on the side, so for instance:
To sort by title: www.example.com/?orderby=title&order=asc
To sort by date: www.example.com/?orderby=date&order=asc
So I want to be able to sort posts using a custom field called "shares" that returns a number , and I use Advanced Custom Fields plugin to generate that field, but not sure how I can generate such query and more importantly, giving a link to apply it if possible.
thanks in advance.
Try this simple code and after making sure that it works, you need to improve it yourself (adding conditions f.e.)
add_action('pre_get_posts','order_post_filter');
function order_post_filter($query){
//then you will need to add some condition here
if (isset($_GET["orderby"]) and isset($_GET["order"])){
$order=$_GET["order"]=='DESC'?'DESC':'ASC';
$query->set('order',$order);
if ($_GET["orderby"]=='date'){
$orderby='date';
}
elseif ($_GET["orderby"]=='title'){
$orderby='title';
}
else {
$query->set('meta_key',$_GET["orderby"]);
$orderby='meta_value';
}
$query->set('orderby',$orderby);
}
}

Is there a suitable hook for intercepting all POSTs to an OpenACS/AOLServer system?

I'd like to disable all POSTs to an OpenACS/AOLServer installation. Is there an good singular place – a request-hook or wrapper/middleware – to do this?
(Bonus points if the intercept can let a few URI patterns or logged-in users through.)
Yes, this is straight forward to do. You have a choice here: you can register a proc to run instead of all POSTs, or can you register a filter to run before the POST and filter out certain users or whatever. I think the filter is a better choice.
To do this you register your proc or filter using ns_register_proc or ns_register_filter (with preauth). Put the following code in a .tcl file under the tcl folder of an OpenACS package or under the main AOLserver /web/servername/tcl directory.
Filter example:
ns_register_filter preauth POST / filter_posts
proc filter_posts {} {
set user_id [ad_verify_and_get_user_id]
set list_of_allowed_user_ids [21 567 8999]
if {[lsearch -exact $list_of_allowed_user_ids $user_id] == -1 } {
#this user isn't allowed - so redirect them
ns_returnredirect "/register/"
# tell AOLserver to abort this thread
return filter_return
} else {
# this user is allowed, tell AOLserver to continue
return filter_ok
}
}
Proc example:
ns_register_proc POST / handle_posts
proc handle_posts {} {
ns_returnredirect "http://someotherwebsite.com"
}

change collection before publishing

I would like to add a property to the objects that get published to the client.
My publish function looks like that
Meteor.publish("forms", function() {
return Forms.find();
});
I would like to do something like this
Meteor.publish("forms", function() {
var forms = Forms.find();
forms.forEach(function (form) {
form.nbForms = 12;
}
return forms;
});
What I would like is that all the documents in forms have a new count attribute which gets sent to the client.
But this obviously does not work.
thank you for your help
Not sure it will work in your case but you might use the new transform collection function introduced with Meteor 0.5.8
When declaring your collection, add this function as the second parameter :
Forms = new Meteor.Collection("forms", {
transform: function(f) {
f.nbForms = 12;
return f;
}
});
But this will be on both server and client. I don't know if there is a way to define a transform function in a publish context.
I think you need to do something similar to this Meteor counting example in Publish:
How does the messages-count example in Meteor docs work?
I also posted a question here that may help once it's answered. Meteor has a this.added which may work, but I'm currently uncertain how to use it. Hence the question below:
Meteor, One to Many Relationship & add field only to client side collection in Publish?

Resources