Here geocode api gives double results - here-api

Some API geocode queries return double results when this is not warranted by the real data.
It will return 2 results with slightly different latitude and longitude and different LocationId's.
This makes it difficult if not impossible to decern which one is the correct result.
Example:
https://geocoder.ls.hereapi.com/6.2/geocode.json?apiKey=8888&city=Zutphen&country=NL
Returns:
{
"Response":{..
},
"View":[
{
"Result":[
{
"Relevance":1.0,
"MatchLevel":"city",
"MatchQuality":{
"City":1.0
},
"Location":{
**"LocationId":"here:cm:namedplace:23055957",**
"LocationType":"point",
**"DisplayPosition":{
"Latitude":52.1402,
"Longitude":6.19152**
},
...
},
"Address":{
"Label":"Zutphen, Gelderland, Nederland",
"Country":"NLD",
"State":"Gelderland",
"County":"Zutphen",
"City":"Zutphen",
"PostalCode":"7201",
"AdditionalData":[
{
"value":"Nederland",
"key":"CountryName"
},
{
"value":"Gelderland",
"key":"StateName"
},
{
"value":"Zutphen",
"key":"CountyName"
}
]
}
}
},
{
"Relevance":1.0,
"MatchLevel":"city",
"MatchQuality":{
"City":1.0
},
"Location":{
**"LocationId":"here:cm:namedplace:20201443",**
"LocationType":"point",
**"DisplayPosition":{
"Latitude":52.13764,
"Longitude":6.20777**
},
...
],
"ViewId":0
}
]
}
}

Related

How to use geographic coordinate with Echarts graph?

I'm trying to use a geographic coordinate with Echarts graph. For example, the graph example given on the website are as follows: [here is the example link about the graph][1]
[![example graph][2]][2]
the data format is as follows:
{
"nodes":[
{
"id":"0",
"name":"Myriel",
"symbolSize":19.12381,
"x":-266.82776,
"y":299.6904,
"value":28.685715,
"category":0
},
{
"id":"1",
"name":"Napoleon",
"symbolSize":2.6666666666666665,
"x":-418.08344,
"y":446.8853,
"value":4,
"category":0
}],
"links":[
{
"source":"1",
"target":"0"
},
{
"source":"2",
"target":"0"
}]}
The document says I can use geographic coordinate with geoIndex to assign the corresponding geographic coordinate components.So I constructed my own graph data which is as follows:
tmp = {
"nodes":[
{
"id":0,
"name":"A",
"x":106.715912,
"y":29.510934,
"value":2.7493110918413546,
"category":0
},
{
"id":1,
"name":"B",
"x":106.375811,
"y":29.242566,
"value":2.4366801109834597,
"category":1
},
{
"id":2,
"name":"C",
"x":106.628127,
"y":29.318595,
"value":1.0339437768234796,
"category":1
},
{
"id":3,
"name":"D",
"x":106.297996,
"y":29.512318,
"value":0.7788528349157652,
"category":0
}
],
"links":[
{
"source":"0",
"target":"1"
},
{
"source":"0",
"target":"2"
},
{
"source":"1",
"target":"2"
},
{
"source":"1",
"target":"3"
}
],
"categories":[
{
"name":"SectionA"
},
{
"name":"SectionB"
}
]
};
Then, I add the corresponding attribute coordinateSystem:'geo',while it does not work. When I comment out this line,it shows like as follows. However, the positional relationship between these points is not as shown in the figure.
[![my graph][3]][3]
So,
[1]: https://echarts.apache.org/examples/zh/editor.html?c=graph
[2]: https://i.stack.imgur.com/gVQeP.png
[3]: https://i.stack.imgur.com/iDNty.png

Repeat values in PAW, POST request

I wanted to ask if it is possible to repeat elements in a POST request in PAW and how to do so?
Basically, given the POST request BODY:
[
{ "zip":"DYNAMIC_VALUE" }
]
Can I then repeat this entry multiple times? Let's say I want to repeat this entry in the array 10 times, I would get for example:
[
{ "zip":"1234" },
{ "zip":"2543" },
{ "zip":"6543" },
{ "zip":"7645" },
{ "zip":"2654" },
{ "zip":"7568" },
{ "zip":"5364" },
{ "zip":"1313" },
{ "zip":"5432" },
{ "zip":"5634" }
]
And maybe I want to send an array with 1000 or more objects with a dynamic zip.
How do I do that?
Thank you :)

Google Analytics: Filter by custom dimension

I'm using the enhanced ecommerce tracking from Google Analytics to send data like this in JS to GA:
ga("ec:addImpression", {
brand: null,
dimension2: "shop123",
id: 1,
list: "Search",
name: "Product 123",
position: 1
});
ga("send", "pageview");
Then, I use the Reporting API to generate some charts. Here, I want to filter by my custom dimension dimension2. The request looks like this:
{
"reportRequests":[
{
"dateRanges":[
{
"startDate":"2016-10-17",
"endDate":"2016-11-16"
}
],
"viewId":"132093148",
"metrics":[
{
"expression":"ga:productListViews"
}
],
"dimensions":[
{
"name":"ga:date"
},
{
"name":"ga:dimension2"
}
],
"dimensionFilterClauses":[
{
"filters":[
{
"dimension_name":"ga:dimension2",
"operator":"EXACT",
"expressions":[
"shop123"
]
}
]
}
]
}
]
}
However, this returns no results:
{
"reports":[
{
"columnHeader":{
"dimensions":[
"ga:date",
"ga:dimension2"
],
"metricHeader":{
"metricHeaderEntries":[
{
"name":"ga:productListViews",
"type":"INTEGER"
}
]
}
},
"data":{
"totals":[
{
"values":[
"0"
]
}
]
}
}
]
}
But when I remove the dimensionFilterClauses I get all the results, of course not filtered by dimension2.
Did I anything wrong when filtering for that dimension?
Change your string dimension_name for dimensionName and try.
As you can see in the examples: https://developers.google.com/analytics/devguides/reporting/core/v4/samples
"dimensionFilter":
{
"dimensionName":"ga:browser",
"operator":"EXACT",
"expressions":["Safari"]
}

Meteor Publish-Composite nesting issue

Problem:
I have a number of groups that each have members that belong to different groups. Each member has a title (role) in each group.
I’m trying to list all the groups and display each member in the group and their title.
I’m using reywood:publish-composite, and everything is working except I can’t get the title of each member to display.
I think the problem is in the Template.groupMembers.helpers file
title: function() {
console.log(this.roleId); // this shows up in the console for each member
return Titles.findOne({titleId: this.roleId}); // but this doesn’t work
},
Collections:
groups {
"_id" : "xFSzAHBEps2dSKcWM",
"name" : "Generic Group",
"logo" : "generic-logo-hi.png"
}
members {
"_id" : "vyDtiaKKukZYQdFvs",
"groupId" : "xFSzAHBEps2dSKcWM",
"memberId" : "hRx8GBTyB5X8iQQ52",
"roleId" : "1"
}
Meteor.users {
"_id" : "hRx8GBTyB5X8iQQ52",
"profile" : {
"name" : "Bob Lorros"
},
}
titles {
"_id" : "bYsKpsyYtyKR8NYpm",
"titleId" : 1,
"title" : "Staff (non-voting)"
}
server/publications/publications.js
Meteor.publishComposite('groupMembers', {
find: function() {
return Groups.find({}, {
sort: {name: 1}
});
},
children: [
{
find: function() {
return Titles.find();
},
find: function(group) {
return Members.find({groupId: group._id});
},
children: [
{
find: function(member) {
return Meteor.users.find({_id: member.memberId});
}
},
]
},
]
});
client/templates/test/test.js
Template.groupMembers.helpers({
groupMembers: function() {
return Groups.find({}, {
sort: {name: 1}
});
},
members: function() {
return Members.find({groupId: this._id});
},
title: function() {
console.log(this.roleId); // this shows up in the console for each member
return Titles.findOne({titleId: this.roleId}); // but this doesn’t work
},
memberName: function() {
return Meteor.users.findOne(this.memberId);
},
});
client/templates/test/test.html
<template name="groupMembers">
<h4>Group - Members</h4>
{{#each groupMembers}}
<b>{{name}}</b><br>
{{#each members}}
{{memberName.profile.name}}
- title = {{title.title}}
<br>
{{/each}}
<br>
{{/each}}
</template>
Output :
This is the ouput
Looking at this from a completely different perspective, I actually think you could use alanning:roles to accomplish exactly what you're looking for. You can use the role as the 'title' in this case and the 'group' to replace your groups. Here's the documentation:
https://github.com/alanning/meteor-roles
Not sure but I think your second find may be overriding your first. Instead of:
find: function() {
return Titles.find();
},
find: function(group) {
return Members.find({groupId: group._id});
},
Try returning an array of cursors.
find: function() {
return [
Titles.find(),
Members.find({groupId: group._id})
];
},
I don't understand however why Titles is a child of GroupMembers when the query for titles is all titles. Did you mean to have a query there?
I think your publishComposite is causing the problem, each object in the children array should have only one find and zero or more children. Also the second parameter in your publication must be a function and not a JSON object. Try this,
Meteor.publishComposite('groupMembers', function () {
return {
find: function() {
return Groups.find({}, {
sort: {name: 1}
});
},
children: [{
find: function() {
return Titles.find();
}
},
{
find: function(group) {
return Members.find({groupId: group._id});
},
children: [{
find: function(member) {
return Meteor.users.find({_id: member.memberId});
}
}]
}]
};
});
You can also improve performance by moving Titles.find to the root level
Meteor.publishComposite('groupMembers', function () {
return [{
find: function() {
return Titles.find();
}
}, {
find: function() {
return Groups.find({}, {
sort: {name: 1}
});
},
children: [{
find: function(group) {
return Members.find({groupId: group._id});
},
children: [{
find: function(member) {
return Meteor.users.find({_id: member.memberId});
}
}]
}]
}];
});

Kendo UI grid with large data set

I am trying Kendo UI out and I am using the examples provided for studying purpose. Let's suppose I am using a large data source of several hundreds of thousand elements. If I'm using paging and the page size is 10, I would really like to be able to get only 10 elements from the web-page and if Kendo UI was able to know that in reality the number of elements is much bigger, but we are showing only 10.
This is what I currently have:
var initGrid = true;
var grid2Data;
function getDataSource()
{
return grid2Data.Data;
}
var grid;
function getPageIndex()
{
if (!(grid)) {
return 0;
}
return grid.pager.page() - 1;
}
function getPageSize() {
if (!(grid)) {
return 10;
}
return grid.pager.pageSize();
}
function getFilters() {
if (!(grid)) {
return "";
}
return grid.dataSource.filter();
}
function getSorts() {
if (!(grid)) {
return "";
}
return grid.dataSource.sort();
}
function getParams() {
return getPageSize();
}
function postTest() {
if (initGrid) {
$.post('myurl' + getParams(), function (data) {
grid2Data = data;
$("#grid").kendoGrid({
dataBound: onDataBound,
dataSource: {
data: getDataSource(),
schema: {
model: {
fields: {
Email: { type: "string" },
FullName: { type: "string" },
LogCreateDate: { type: "date" },
RoleName: { type: "string" },
UserName: { type: "string" }
}
}
},
pageSize: 10
},
height: 300,
scrollable: false,
sortable: true,
filterable: true,
pageable: {
input: true,
numeric: false
},
columns: [
{
field: "Email",
title: "Email",
width: 100
},
{
field: "FullName",
title: "Full Name",
width: 100
},
{
field: "LogCreateDate",
title: "Created",
template: '#= kendo.toString(LogCreateDate,"MM/dd/yyyy") #'
},
{
field: "RoleName",
title: "Role",
width: 50
},
{
field: "UserName",
width: 100
}
]
});
grid = $("#grid").data("kendoGrid");
});
}
else {
}
initGrid = false;
}
$(document).ready(function () {
postTest();
});
My problem is that the grid is showing that this is element 1-10 from 10 and it's the first page. I would like the grid to show me a page index and item count given by me. How can I set the number of elements and the page index of the grid? Is this possible? Thanks.
When you choose serverPaging in the DataSource by setting it to true. You receiver in the server information about the page number (page), the page size (pageSize), number of records to skip (skip)... (look for serverPaging in http://docs.kendoui.com/api/framework/datasource) and in exchange you should return not only the array with the data of that page but also the total number of rows. Then you implement in schema.total the function for accessing the number of records. I.e. Lets assume that you return as result the following object:
{
rows: [
{ id: 1, col1: "col1.1", col2: "col1.2" },
{ id: 2, col1: "col2.1", col2: "col2.2" },
{ id: 3, col1: "col3.1", col2: "col3.2" }
],
totalRows : 1000
}
Then you might implement schema.total as:
schema: {
total: function (response) {
return response.totalRows;
}
}
Where response is the object received from the server.
NOTE: Actually in this case would be enough defining the schema as:
schema: {
total: "totalRows";
}
}
Since total is directly stored in totalRows field.
Check http://demos.kendoui.com/web/grid/remote-data.html for an example.

Resources