HERE-API How to configure the poi filter when requesting map tiles - here-api

I would like to filter the POIs added to my map tiles to some category but I don't understand how to move from the POI categories available in the meta-data to the hexadecimal filter. The example provided in the developer documentation is too simple.
For example if I want to have only city halls (category 323), which value should I put for the pois attribute of my request?
And if I want to combine it with Fire Departments (category 246)?
Thank you for your help

The hexadecimal value for city halls (category 323) is 000000000000000000000000000000000000000000000000000000000000000000000000000000001.
For Fire Department (category 246) it is 00000000000000000000000000000000000000000000000000000000000002.
You can use the map table (provided in the link) in your program code or you can calculate the HEX values in runtime utilize this code snippet:
// 1. get poi categories /meta/pois?output=json and store them in a list
// 2. create a list with inputs of type checkbox
// 3. create a 'change' listener that includes the following logic
var bit, bits = '0', hex = '', n=1;
// please pay attention as the index starts on '1' as the
// first bit is always initialized to '0' because it is a reserved bit
$('.poi').each(function {
bit = $(this).is(':checked') ? '1' : '0';
bits = bits + bit;
if ((n+1)%4 == 0)
{ hex = hex + parseInt(bits, 2).toString(16); bits = ''; }
n = n + 1
});
if (bits !== '') hex = hex + parseInt(bits, 2).toString(16);
// we remove the trailing zeroes as they are not needed
hex = hex.replace(/0+$/g, '');
// trigger a map update using the parameter &pois=hex

Related

image.filter is not a function in google earth engine

As a newbie to the google earth engine, I have been trying something (https://code.earthengine.google.com/6f45059a59b75757c88ce2d3869fc9fd) following a NASA tutorial (https://www.youtube.com/watch?v=JFvxudueT_k&ab_channel=NASAVideo). My last line (line 60) shows image.filter is not a function, while the one in the tutorial (line 34) is working. I am not sure what happened and how to sort this out?
//creating a new variable 'image' from the L8 collection data imported
var image = ee.Image (L8_tier1 //the details in the data will represent that the band resolution is 30m
//the details in the data will represent that the band resolution is 30m
//.filterDate ("2019-07-01","2021-10-03") //for a specific date range. maybe good to remove it for the function.
//the details in the data will represent that the band resolution is 30m
//the details in the data will represent that the band resolution is 30m
//.filterDate ("2019-07-01","2021-10-03") //for a specific date range. maybe good to remove it for the function.
.filterBounds (ROI) //for the region of interest we are interested in
//.sort ("COLUD_COVER") //for sorting the data between the range with a cloud cover, the metadata property we are interested in. Other way to do this is using the function below.
//.first() //this will make the image choose the first image with the least amount of cloud cover for the area. Other way to do this is using the function below.
);
//print ("Hague and Rotterdam", image); //printing the image in the console
//console on the right hand side will explain everything from the data
//id will show the image deatils and date of the image, for this case 29th July 2019
//under the properties tab cloud cover can be found, this is the least we can get for this area during this period
// //vizualisation of the data in the map with true color rendering
// var trueColour = {
// bands:["SR_B4","SR_B3","SR_B2"],
// min: 5000,
// max: 12000
// };
// Map.centerObject (ROI, 12); //for the centering the area in the center of the map with required zoom level
// Map.addLayer (image, trueColour, "Hague and Rotterdam"); //for adding the image with the variable of bands we made and naming the image
//Alternate way
//Function to cloud mask from the qa_pixel band of Landsat 8 SR data. In this case bits 3 and 4 are clouds and cloud shadow respectively. This can be different for different image sets.
function maskL8sr(image) {
var cloudsBitMask = 1 << 3; //remember to check this with the source
var cloudshadowBitMask = 1 << 4; //remember to check this with the source
var qa = image.select ('qa_pixel'); //creating the new variable from the band of the source image
var mask = qa.bitwiseAnd(cloudsBitMask).eq(0) //making the cloud equal to zero to mask them out
.and(qa.bitwiseAnd(cloudshadowBitMask).eq(0)); //making the cloud shadow equal to zero to mask them out
return image.updateMask(mask).divide(10000)
.select("SR_B[0-9]*")
.copyProperties(image, ["system:time_start"]);
}
// print ("Hague and Rotterdam", image);// look into the console now. How many images the code have downloaded!!!
//filtering imagery for 2015 to 2021 summer date ranges
//creating joint filter and applying to image collection
var sum21 = ee.Filter.date ('2021-06-01','2021-09-30');
var sum20 = ee.Filter.date ('2020-06-01','2020-09-30');
var sum19 = ee.Filter.date ('2019-06-01','2019-09-30');
var sum18 = ee.Filter.date ('2018-06-01','2018-09-30');
var sum17 = ee.Filter.date ('2017-06-01','2017-09-30');
var sum16 = ee.Filter.date ('2016-06-01','2016-09-30');
var sum15 = ee.Filter.date ('2015-06-01','2015-09-30');
var SumFilter = ee.Filter.or(sum21, sum20, sum19, sum18, sum17, sum16, sum15);
var allsum = image.filter(SumFilter);
Filtering is an operation you can do on ImageCollections, not individual Images, because all filtering does is choose a subset of the images. Then, in your script, you have (with the comments removed):
var image = ee.Image (L8_tier1
.filterBounds (ROI)
);
The result of l8_tier1.filterBounds(ROI) is indeed an ImageCollection. But in this case, you have told the Earth Engine client that it should be treated as an Image, and it believed you. So, then, the last line
var allsum = image.filter(SumFilter);
fails with the error you saw because there is no filter() on ee.Image.
The script will successfully run if you change ee.Image(...) to ee.ImageCollection(...), or even better, remove the cast because it's not necessary — that is,
var image = L8_tier1.filterBounds(ROI);
You should probably also change the name of var image too, since it is confusing to call an ImageCollection by the name image. Naming things accurately helps avoid mistakes, while you are working on the code and also when others try to read it or build on it.

Gravity forms conditional logic based on number of values selected

I have a form built with gravity forms that asks 5 questions, each with 2 answers.
Each answer corresponds to a category, and so I want to be able to add some conditional logic so that the confirmation sends to a different page depending on which category has more answers.
Form is here: https://90daysfromretirement.com/medicare-advantage-vs-medicare-supplement/
The two categories are "Advantage" and "Supplement" - so dependng on the answer, so whichever category has more responses (3 or greater) then the confirmation will redirect them to the appropriate page.
Problem is I can't figure out how to Count the values for each and run logic off it. I don't think it's possible with any gravity forms add-ons I've found, and I haven't been able to put the code together to do it.
Any suggestions?
Since you only have two options, you really only need to know the count of one and the total number of questions to know which value has been selected more.
For example, if you have 10 questions and "Advantage" choices are selected 6 times, you know that Advantage has more than "Supplement".
Here's a snippet that should get you started. It will take a group of Radio Button fields, count the number of times a specified value has been selected, and populate that count into a Number field.
You can then use that Number field to apply conditional logic on your confirmations to redirect to the appropriate page (e.g. If Count is greater than 5, redirect to Advantage page. If Count is less than 6, redirect to Supplement page).
/**
* Gravity Wiz // Gravity Forms // Value Counter
* https://gravitywiz.com/
*
* Count the number of times a given value has been selected in a group of fields and populate that number into a Number field.
* This snippet is designed to target a Number field and count selected values in Checkbox and Radio Button fields.
*
* This snippet works best with our free [GF Custom Javascript](https://gravitywiz.com/gravity-forms-custom-javascript/) plugin.
*/
// Replace the "1", "2" and "3" with field IDs of fields that should have their selected values counted. If you are using the
var $radios = jQuery( '#field_GFFORMID_1, #field_GFFORMID_2, #field_GFFORMID_3' );
// Replace "4" with the ID of the Number field in which the count should be populated.
var $target = jQuery( '#field_GFFORMID_4' );
// Replace "a" with the value you wish to count if selected.
var countValue = 'a';
function gwRecountValues() {
$target.find( 'input' ).val( $radios.find( 'input:checked[value="' + countValue + '"]' ).length );
}
$radios.on( 'change', function() {
gwRecountValues();
} );
gwRecountValues();
And here's the source which may be updated in the future if other folks use this and experience any issues or need improvements: https://github.com/gravitywiz/snippet-library/commit/d34eb169da937981c4a1ea49bb8a36df023bff1b
The one thing missing from this snippet is PHP validation. You may not be concerned about people altering their count but it is possible without PHP validation.
You could try adding the following to your functions.php file
add_action( "gform_after_submission_66", "after_submission", 10, 2 ); //replace 66 with your form number
function after_submission($entry, $form ){
$supplement_answers = array("milk", "apple", "pasta", "fries", "oats"); //replace array items with the supplement answers
$advantage_answers = array("red", "blue", "pink", "purple", "yellow"); //replace array items with the advantage answers
$field_nums = array("2","3","6","7","9"); //replace these field numbers with your own -- order then to align with answers above
$count_fields = count($field_nums);
$a = 0;
$b = 0;
for($i=0; $i<$count_fields; $i++){
if($entry[$field_nums[$i]] == $supplement_answers[$i]){
$a = $a + 1;
}else if($entry[$field_nums[$i]] == $advantage_answers[$i]){
$b = $b + 1;
}
}
if($a > $b){
header('Location: https://website/supplements_page'); //replace url
}else if($a < $b){
header('https://website/advantage_page'); //replace url -
}
}

Adobe Catalyst - 'Attribute Price' adding on to 'Sell Price' Issue

I have set a products sell price at £100. I have also created a 'Size' attribute at 'Large' £120.
But when I view the product and select 'Large' it prices up at £220 (adding the attribute and sell price together) when I'm wanting it at just the £120.
Any thoughts on why I'm getting this issue?
I believe Daut maybe talking about something else but I could be wrong.
When using attributes that you talk about, the price is calculated by default price plus the attribute price. This is why you see £220 as your total, as you have figured out.
In other words, your default price is £100. For your total to be £120, then your Large attribute would actually be £20. When it adds together, your total price will be £120.
When I use attributes with varying cost, I typically write my attribute as:
Large + [then BC inserts the price.]
On the BC App Store, there are a couple plugins (here and here) that assist with using Attributes. Their main purpose, from my understanding, is controling how the information is displayed to customers. I have no experience using either of these but it may help you.
Hi have created my own way around this issue in BC I also shared it on Business Catalyst Forum too. for select dropdown or radio buttons use the code bellow, you need to have a certain code ability to mend it together, it was quite done some time ago but if somebody interested on improving it to a cleaner way be welcome to share.
$(document).ready(function(){
StartDynamicPrice();
DoPriceChange();
});
var el_totalprice='#totalprice';
var el_totalprice_gst='#totalprice_gst';
//var el_attrselect='.catProdAttributeItem select';
// uncomment if you want radio as well
var el_attrselect='.catProdAttributeItem select, .catProdAttributeItem input';
var currencysymbol='£';
Number.prototype.toMoney=function(decimals, decimal_sep, thousands_sep){
var n = this,
c = isNaN(decimals) ? 2 : Math.abs(decimals),
d = decimal_sep || '.',
t = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
sign = (n < 0) ? '-' : '',
i = parseInt(n = Math.abs(n).toFixed(c)) + '',
j = ((j = i.length) > 3) ? j % 3 : 0;
return sign + (j ? i.substr(0, j) + t : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : '');
}
DoPriceChange=function(){
var selected='';
var newsubtotal=0;
$.each($(el_attrselect), function(i,e){
selected=$(e).children(':selected').text();
if (selected.indexOf(currencysymbol) != -1){
newsubtotal+=parseFloat(selected.substring(selected.indexOf(currencysymbol)+1));
};
});
newtotal=parseFloat($(el_totalprice).attr('base'))+parseFloat(newsubtotal);
newtotal_gst=newtotal+(newtotal*.10);
$(el_totalprice).html(currencysymbol+newtotal.toMoney());
$(el_totalprice_gst).html(currencysymbol+newtotal_gst.toMoney());
}
StartDynamicPrice=function(){
$(el_totalprice).attr('base',$(el_totalprice).html().replace(currencysymbol,'').replace(' ,','')); // set base price
$(el_attrselect).on('change',function(){
DoPriceChange();
})
}
/// END
Attributes in BC are add-ons. You cannot just get the attribute.
What you need is product grouping.
Group products together
You can create multiple products of the same type and group them together. A customer viewing one product can also see the available variations by selecting another product from the group.
Check how Grouping works in Business Catalyst
From the Actions menu, select Group Products Together.
Move the products from the left panel to the right, select a default product, and click Save.
Note: The default product is the only product that displays in a catalog. All other grouped products are available through the grouped product drop-down menu.

METEOR - Automatically increment order numbers

What I need to do is use either collection-2 or another package to automatically create a new order number, incremented from the last order number used.
i.e. Starting off with PO123456, when I save this order, the next time I make a new PO, it automatically generates the number PO123457.
I've been looking for a good example or tutorial, but I'm not able to find one.
Using konecty:mongo-counter in conjuntion with aldeed:collection2 and aldeed:simple-schema should be pretty straightforward. In your schema definition try:
POnumber: { type: String, autoValue: function(){
if ( this.isInsert ){ // restrict to when inserting a document
var currentNumber = incrementCounter('purchase order'); // this will use mongo-counter
// WARNING: you can only ever get as rich as 10M POs!!
var zeroPad = "000000" + currentNumber; // pad with 6 zeros
zeroPad = zeroPad.substr(zeroPad.length-7); // restrict to 7 places
return 'PO' + zeroPad; // prefix with 'PO'
} else if ( this.isSet ){
this.unset(); // prevent attempts to change the number
}
}

Encoding key strokes as bits in uint

Hey,
I m trying to encode certain values that i receive from keyboard event.
Basically i want to check if a certain key combination has been pressed or not, so for that i m converting the key codes into sequence/pattern and store it in an object and a value(function) against each code sequence.
Now i have to use four bytes and in first byte(MSB) i ve to store shift, alt, ctrl respectively and in the last(LSB) i have to store the keycode of the key pressed.
Here is the code:
private function m_encodeValue(key:String, Ctrl:Boolean = true, Alt:Boolean = true, Shift:Boolean = false):uint
{
var encodedValue:uint;
encodedValue = uint(Shift) << 2 | uint(Alt) << 1 | uint(Ctrl);
encodedValue = encodedValue | (uint(key.toUpperCase().charCodeAt(0)) << 24);
return encodedValue;
}
I store a sequence in an object and its corresponding value which is a function reference, then when certain key combination is pressed it is converted into sequence and check against those entries, after which Function is called.
What i was doing wrong, i was using Key_down event, i instead used Key_up, so now all the values, say ctrl + atl + v, get dispatched in the event object altogether. Whereas in Key_down case on every key press the event was firing up, making it hard to cull the keycodes i needed.

Resources