Nifi - Extract list with a jolt - list

I have a JSON with this array 'itens':
obs: I need to fetch this array when performing the transform.
{
"PreNotaFiscal": {
"numero": "19646801",
"serie": "1",
"observacao": "C5_LVMENSR:REF.PROPOSTA 589112 PEDIDO 034792 - 008|C5_MENNOTA:REF.PROPOSTA 589112 PEDIDO 034792 - 008 PRODUTO IMPORTADO SOB REGIME DE DIFERIMENTO, DEC. N 4.316/95. |C5_LVMENSR:REF.PROPOSTA 589112 PEDIDO 034792 - 008|C5_LVLOGIS:LOCAL DA COLETA SALVADOR: TOPLOG ARMAZENAGEM - VIA URBANA, KM 01 S/N - CIA SUL - SIMOES FILHO/BA - CEP:43700-000",
"modalidadeFrete": 0,
"naturezaOperacao": "",
"canalDistribuicao": "",
"tipoOperacao": 1,
"dataEmissao": "20220513",
"peso": 4.3,
"pesoLiquido": 4.3,
"pesoCubado": 0,
"cubagem": 0.017,
"volumes": 1,
"quantidadeItens": 0,
"valor": 10229.86,
"valorProdutos": 10229.86,
"codigoProduto": "1",
"cnpjUnidade": "",
"prazoCliente": ""
},
"emitente": {
"cnpj": "05917486000140",
"nome": "LIVETECH DA BAHIA INDUSTRIA E COM. S.A",
"fantasia": "LIVETECH DA BAHIA INDUSTRIA E COM. S.A",
"inscricaoEstadual": "63250303",
"logradouro": "RODOVIA BA 262 - POLO DE INFORMATICA DE ILHEUS",
"bairro": "IGUAPE",
"codigoMunicipio": "2913606",
"cep": "45658335",
"fone": "(73) 3222-5250"
},
"destinatario": {
"cnpj": "09356818000116",
"nome": "INTERNET PLAY LTDA",
"fantasia": "NETPLAY",
"inscricaoEstadual": "177269246112",
"email": "financeiro#netplay.net.br",
"bairro": "JARDIM PLANALTO",
"estado": "SP",
"codigoMunicipio": "02804",
"cep": "16072340",
"fone": "(18) 3117-7434"
},
"itens": [
{
"produto": "1000196100663",
"nomeProduto": "XA1DTCHUS - XGS 136 Dispositivo de seguran�a - cabo de alime",
"cubagem": 0.017,
"quantidade": 1,
"volumes": 1,
"valor": 9321.06,
"codigoClassificacaoProduto": "100"
}
],
"volumes": [
{
"item": "01",
"quantidade": 1,
"altura": 0.15,
"largura": 0.28,
"comprimento": 0.41,
"volume": 0.017,
"pesoPorVolume": 4.3,
"pesoTotal": 4.3,
"tipoVolume": "PCT 08"
}
]
}
I transform:
[
{
"operation": "shift",
"spec": {
"PreNotaFiscal": {
"numero": "numero",
"serie": "serie",
"observacao": "observacao",
"modalidadeFrete": "modalidadeFrete",
"naturezaOperacao": "naturezaOperacao",
"canalDistribuicao": "canalDistribuicao",
"tipoOperacao": "tipoOperacao",
"dataEmissao": "dataEmissao",
"peso": "peso",
"pesoLiquido": "pesoLiquido",
"pesoCubado": "pesoCubado",
"cubagem": "cubagem",
"volumes": "volumes",
"quantidadeItens": "quantidadeItens",
"valor": "valor",
"valorProdutos": "valorProdutos",
"codigoProduto": "codigoProduto",
"prazoCliente": "prazoCliente"
},
"emitente": {
"cnpj": "emitente.cnpj",
"nome": "emitente.nome",
"fantasia": "emitente.fantasia",
"inscricaoEstadual": "emitente.inscricaoEstadual",
"logradouro": "emitente.logradouro",
"bairro": "emitente.bairro",
"codigoMunicipio": "emitente.codigoMunicipio",
"cep": "emitente.cep",
"fone": "emitente.fone"
},
"destinatario": {
"cnpj": "destinatario.cnpj",
"nome": "destinatario.nome",
"fantasia": "destinatario.fantasia",
"inscricaoEstadual": "destinatario.inscricaoEstadual",
"email": "destinatario.email",
"bairro": "destinatario.bairro",
"codigoMunicipio": "destinatario.codigoMunicipio",
"cep": "destinatario.cep",
"fone": "destinatario.fone"
}
}
},
{
"operation": "default",
"spec": {
"cnpjUnidade": "${cnpjEmissor:unescapeJson()}"
}
}
]
But I need to bring the values and the array of the "itens", example:
{
"numero" : "19646801",
"serie" : "1",
"observacao" : "C5_LVMENSR:REF.PROPOSTA 589112 PEDIDO 034792 - 008|C5_MENNOTA:REF.PROPOSTA 589112 PEDIDO 034792 - 008 PRODUTO IMPORTADO SOB REGIME DE DIFERIMENTO, DEC. N 4.316/95. |C5_LVMENSR:REF.PROPOSTA 589112 PEDIDO 034792 - 008|C5_LVLOGIS:LOCAL DA COLETA SALVADOR: TOPLOG ARMAZENAGEM - VIA URBANA, KM 01 S/N - CIA SUL - SIMOES FILHO/BA - CEP:43700-000",
"modalidadeFrete" : 0,
"naturezaOperacao" : "",
"canalDistribuicao" : "",
"tipoOperacao" : 1,
"dataEmissao" : "20220513",
"peso" : 4.3,
"pesoLiquido" : 4.3,
"pesoCubado" : 0,
"cubagem" : 0.017,
"volumes" : 1,
"quantidadeItens" : 0,
"valor" : 10229.86,
"valorProdutos" : 10229.86,
"codigoProduto" : "1",
"prazoCliente" : "",
"emitente" : {
"cnpj" : "05917486000140",
"nome" : "LIVETECH DA BAHIA INDUSTRIA E COM. S.A",
"fantasia" : "LIVETECH DA BAHIA INDUSTRIA E COM. S.A",
"inscricaoEstadual" : "63250303",
"logradouro" : "RODOVIA BA 262 - POLO DE INFORMATICA DE ILHEUS",
"bairro" : "IGUAPE",
"codigoMunicipio" : "2913606",
"cep" : "45658335",
"fone" : "(73) 3222-5250"
},
"destinatario" : {
"cnpj" : "09356818000116",
"nome" : "INTERNET PLAY LTDA",
"fantasia" : "NETPLAY",
"inscricaoEstadual" : "177269246112",
"email" : "financeiro#netplay.net.br",
"bairro" : "JARDIM PLANALTO",
"codigoMunicipio" : "02804",
"cep" : "16072340",
"fone" : "(18) 3117-7434"
},
"cnpjUnidade" : "${cnpjEmissor:unescapeJson()}",
"itens": [
{
"produto": "1000196100663",
"nomeProduto": "XA1DTCHUS - XGS 136 Dispositivo de seguran�a - cabo de alime",
"cubagem": 0.017,
"quantidade": 1,
"volumes": 1,
"valor": 9321.06
}
}
If there are more items, they will be inserted together.
Example:
Itens: [{
"produto": "1000196100663",
"nomeProduto": "XA1DTCHUS - XGS 136 Dispositivo de seguran�a - cabo de alime",
"cubagem": 0.017,
"quantidade": 1,
"volumes": 1,
"valor": 9321.06
},
{ "produto": "1000196100663",
"nomeProduto": "XA1DTCHUS - XGS 136 Dispositivo de seguran�a - cabo de alime",
"cubagem": 0.017,
"quantidade": 1,
"volumes": 1,
"valor": 9321.06}
]
Now i detailed with the whole json.
Can someone help me?

No need to rewrite all sub-attibutes, but put only the main nodes within a shift transformation spec, and then remove the extra ones, and default the desired one such as
[
{
"operation": "shift",
"spec": {
"#PreNotaFiscal": "", // bring the object except the key
"emitente": "&", // replicate all listed object as a whole
"destinatario": "&",
"itens": "&"
}
},
{
"operation": "remove",
"spec": {
"itens": {
"*": {
"codigoClas*": ""
}
},
"cnpjUn*": ""
}
},
{
"operation": "default",
"spec": {
"cnpjUnidade": "${cnpjEmissor:unescapeJson()}"
}
}
]
where a suitable abbreviation for the literal codigoClassificacaoProduto such as codigoClas, along with the replacement wildcard * might be used as in the current case.

Related

Wrong geocode results

We're trying to geocode a location in Poland, using a street, zip code and a city name, but seem to get wrong result. We're looking for: DĄBROWSKIEGO , 82-300 ELBLĄG
Request:
https://geocoder.ls.hereapi.com/6.2/geocode.json?apiKey={API_KEY}&searchtext=D%C4%84BROWSKIEGO%2B,%2B82-300%2BELBL%C4%84G
Instead of a road of that name in the city of Elbląg we get a street of the same name in Poznań:
{
"Response": {
"MetaInfo": {
"Timestamp": "2021-05-11T10:40:48.113+0000"
},
"View": [
{
"Result": [
{
"Relevance": 0.65,
"MatchLevel": "houseNumber",
"MatchQuality": {
"Street": [
0.5
],
"HouseNumber": 1.0
},
"MatchType": "pointAddress",
"Location": {
"LocationId": "here:af:streetsection:nKjv5QtDTbhcQ-QErVaJvA:CgcIBCDCwO9pEAEaAzMwMA",
"LocationType": "point",
"DisplayPosition": {
"Latitude": 52.42663,
"Longitude": 16.85675
},
"NavigationPosition": [
{
"Latitude": 52.42678,
"Longitude": 16.85687
}
],
"MapView": {
"TopLeft": {
"Latitude": 52.42753,
"Longitude": 16.85528
},
"BottomRight": {
"Latitude": 52.42573,
"Longitude": 16.85822
}
},
"Address": {
"Label": "ulica gen. Jana H. Dąbrowskiego 300, 60-406 Poznań, Polska",
"Country": "POL",
"State": "Woj. Wielkopolskie",
"County": "Poznań",
"City": "Poznań",
"District": "Poznań",
"Subdistrict": "Jeżyce",
"Street": "ulica gen. Jana H. Dąbrowskiego",
"HouseNumber": "300",
"PostalCode": "60-406",
"AdditionalData": [
{
"value": "Polska",
"key": "CountryName"
},
{
"value": "Woj. Wielkopolskie",
"key": "StateName"
},
{
"value": "Poznań",
"key": "CountyName"
}
]
}
}
}
],
"ViewId": 0
}
]
}
}
Trying to use newer api gives the same results:
https://geocode.search.hereapi.com/v1/geocode?apiKey={API_KEY}&q=D%C4%84BROWSKIEGO%2B,%2B82-300%2BELBL%C4%84G
{
"items": [
{
"title": "ulica gen. Jana H. Dąbrowskiego 300, 60-406 Poznań, Polska",
"id": "here:af:streetsection:nKjv5QtDTbhcQ-QErVaJvA:CgcIBCDCwO9pEAEaAzMwMA",
"resultType": "houseNumber",
"houseNumberType": "PA",
"address": {
"label": "ulica gen. Jana H. Dąbrowskiego 300, 60-406 Poznań, Polska",
"countryCode": "POL",
"countryName": "Polska",
"state": "Woj. Wielkopolskie",
"county": "Poznań",
"city": "Poznań",
"district": "Poznań",
"subdistrict": "Jeżyce",
"street": "ulica gen. Jana H. Dąbrowskiego",
"postalCode": "60-406",
"houseNumber": "300"
},
"position": {
"lat": 52.42663,
"lng": 16.85675
},
"access": [
{
"lat": 52.42678,
"lng": 16.85687
}
],
"mapView": {
"west": 16.85528,
"south": 52.42573,
"east": 16.85822,
"north": 52.42753
},
"scoring": {
"queryScore": 0.65,
"fieldScore": {
"streets": [
0.5
],
"houseNumber": 1.0
}
}
}
]
}
Looking for a different street in the city of Elbląg gives us proper result:
Łęczycka, 82-300 ELBLĄG
https://geocoder.ls.hereapi.com/6.2/geocode.json?apiKey={API_KEY}&searchtext=%C5%81%C4%99czycka%2B,%2B82-300%2BELBL%C4%84G
{
"Response": {
"MetaInfo": {
"Timestamp": "2021-05-11T10:43:15.578+0000"
},
"View": [
{
"Result": [
{
"Relevance": 0.99,
"MatchLevel": "street",
"MatchQuality": {
"City": 1.0,
"Street": [
0.9
],
"PostalCode": 1.0
},
"Location": {
"LocationId": "here:af:street:SHP1-8Tzm6jtHKMvaFxTLA",
"LocationType": "point",
"DisplayPosition": {
"Latitude": 54.16571,
"Longitude": 19.46824
},
"NavigationPosition": [
{
"Latitude": 54.16571,
"Longitude": 19.46824
}
],
"MapView": {
"TopLeft": {
"Latitude": 54.17117,
"Longitude": 19.43421
},
"BottomRight": {
"Latitude": 54.15544,
"Longitude": 19.50485
}
},
"Address": {
"Label": "ulica Łęczycka, 82-300 Elbląg, Polska",
"Country": "POL",
"State": "Woj. Warmińsko-Mazurskie",
"County": "Elbląg",
"City": "Elbląg",
"District": "Elbląg",
"Street": "ulica Łęczycka",
"PostalCode": "82-300",
"AdditionalData": [
{
"value": "Polska",
"key": "CountryName"
},
{
"value": "Woj. Warmińsko-Mazurskie",
"key": "StateName"
},
{
"value": "Elbląg",
"key": "CountyName"
}
]
}
}
}
],
"ViewId": 0
}
]
}
}
Is there anything we're doing wrong when invoking the requests?
Now it returns correct results:
https://geocoder.ls.hereapi.com/6.2/geocode.json?language=en-US&maxresults=20&searchtext=D%C4%84BROWSKIEGO+82-300+ELBL%C4%84G&apikey=***
Result:
{
"Response": {
"MetaInfo": {
"Timestamp": "2021-07-20T12:23:56.560+0000"
},
"View": [
{
"_type": "SearchResultsViewType",
"ViewId": 0,
"Result": [
{
"Relevance": 1,
"MatchLevel": "street",
"MatchQuality": {
"City": 1,
"Street": [
0.57
],
"PostalCode": 1
},
"Location": {
"LocationId": "NT_mqHTX7fWyBVgpiaYyp.VAB",
"LocationType": "point",
"DisplayPosition": {
"Latitude": 54.15047,
"Longitude": 19.45583
},
"NavigationPosition": [
{
"Latitude": 54.15047,
"Longitude": 19.45583
}
],
"MapView": {
"TopLeft": {
"Latitude": 54.15449,
"Longitude": 19.44247
},
"BottomRight": {
"Latitude": 54.15029,
"Longitude": 19.46051
}
},
"Address": {
"Label": "ulica gen. Jarosława Dąbrowskiego, 82-300 Elbląg, Poland",
"Country": "POL",
"State": "Woj. Warmińsko-Mazurskie",
"County": "Elbląg",
"City": "Elbląg",
"District": "Elbląg",
"Street": "ulica gen. Jarosława Dąbrowskiego",
"PostalCode": "82-300",
"AdditionalData": [
{
"value": "Poland",
"key": "CountryName"
},
{
"value": "Woj. Warmińsko-Mazurskie",
"key": "StateName"
},
{
"value": "Elbląg",
"key": "CountyName"
}
]
}
}
}
]
}
]
}
}
This GS7 request
https://search.hereapi.com/v1/geocode?q=D%C4%84BROWSKIEGO+82-300+ELBL%C4%84G&at=51.9206796%2C17.2954345&lang=en-US&limit=20&apikey=***
returns incorrect result - but will be fixed soon.

AWS Terraform cloudwatch - Dashboard body reading from a list

I have the following body for my AWS_CloudWatch_Resource on terraform:
dashboard_body = jsonencode(
dashboard_body = jsonencode(
{
"widgets": [
{
"type": "metric",
"x": 0,
"y": 0,
"width": 9,
"height": 6,
"properties": {
"view": "bar",
"stacked": false,
"metrics": [
[ "AWS/AutoScaling", "GroupDesiredCapacity", "AutoScalingGroupName", "Momo-Test-ASG1" ],
[ ".", "GroupMaxSize", ".", "." ],
[ ".", "GroupTotalCapacity", ".", "." ],
[ ".", "GroupTotalInstances", ".", "." ],
[ ".", "GroupInServiceInstances", ".", "." ]
],
"region": "eu-central-1",
"title": "ASG1 statistics"
}
},
{
"type": "metric",
"x": 9,
"y": 0,
"width": 9,
"height": 6,
"properties": {
"view": "bar",
"stacked": false,
"metrics": [
[ "AWS/AutoScaling", "GroupDesiredCapacity", "AutoScalingGroupName", "Momo-Test-ASG2" ],
[ ".", "GroupMaxSize", ".", "." ],
[ ".", "GroupTotalCapacity", ".", "." ],
[ ".", "GroupTotalInstances", ".", "." ],
[ ".", "GroupInServiceInstances", ".", "." ]
],
"region": "eu-central-1",
"period": 300,
"title": "ASG2 statistics"
}
},
{
"type": "explorer",
"x": 0,
"y": 6,
"width": 24,
"height": 15,
"properties": {
"metrics": [
{
"metricName": "CPUUtilization",
"resourceType": "AWS::EC2::Instance",
"stat": "Average"
},
{
"metricName": "NetworkIn",
"resourceType": "AWS::EC2::Instance",
"stat": "Average"
},
{
"metricName": "DiskReadOps",
"resourceType": "AWS::EC2::Instance",
"stat": "Average"
},
{
"metricName": "DiskWriteOps",
"resourceType": "AWS::EC2::Instance",
"stat": "Average"
},
{
"metricName": "NetworkOut",
"resourceType": "AWS::EC2::Instance",
"stat": "Average"
}
],
"aggregateBy": {
"key": "*",
"func": "AVG"
},
"labels": [
{
"key": "aws:autoscaling:groupName",
"value": "Momo-Test-ASG1"
},
{
"key": "aws:autoscaling:groupName",
"value": "Momo-Test-ASG2"
}
],
"widgetOptions": {
"legend": {
"position": "bottom"
},
"view": "timeSeries",
"stacked": false,
"rowsPerPage": 40,
"widgetsPerRow": 3
},
"period": 300,
"splitBy": "",
"title": "Average ASG1 and ASG2"
}
},
{
"type": "metric",
"x": 0,
"y": 21,
"width": 6,
"height": 6,
"properties": {
"metrics": [
[ { "expression": "AVG(METRICS())", "label": "Average", "id": "e1" } ],
[ "CWAgent", "mem_used_percent", "InstanceId", "i-0f67225a5c04aebf9", "AutoScalingGroupName", "Momo-Test-ASG2", "ImageId", "ami-0502e817a62226e03", "InstanceType", "t2.micro", { "yAxis": "left", "id": "m1" } ],
[ "...", "i-00198c860886391f4", ".", "Momo-Test-ASG1", ".", ".", ".", ".", { "id": "m2" } ]
],
"view": "timeSeries",
"stacked": false,
"region": "eu-central-1",
"period": 300,
"stat": "Average",
"title": "mem_used_percent"
}
}
]
}
)
}
As you can see, I am having the same widget for my Momo-Test-ASG1 ( first Autoscaling group ) and Momo-Test-ASG2 ( second Autenter code here scaling group ).
If I would have many ASGs to test, It would be problematic to hardcode the same thing for a lot of groups.
Is there any solution to make terraform read the ASGs from a list? instead of having to reproduce the same parts?
HashiCorp Terraform 0.12 Preview: For and For-Each
Using for
locals {
asg_names = [
"Momo-Test-ASG1",
"Momo-Test-ASG2",
]
}
locals {
body = [for asg_name in local.asg_names :
{
type: "metric",
x: 0,
y: 0,
width: 9,
height: 6,
properties: {
view: "bar",
stacked: false,
metrics: [
[ "AWS/AutoScaling", "GroupDesiredCapacity", "AutoScalingGroupName", asg_name ],
[ ".", "GroupMaxSize", ".", "." ],
[ ".", "GroupTotalCapacity", ".", "." ],
[ ".", "GroupTotalInstances", ".", "." ],
[ ".", "GroupInServiceInstances", ".", "." ]
]
region: "eu-central-1",
title: asg_name
}
}
]
}
resource "aws_cloudwatch_dashboard" "main" {
dashboard_name = "my-dashboard"
dashboard_body = jsonencode({
widgets: concat(local.body, [{
type: "text",
x: 0,
y: 7,
width: 3,
height: 3,
properties: {
markdown: "Hello world"
}
}])
})
}

icCube gauge with multiple band colors

I'm trying to make a gauge and want to have two band colors (wrong/red, good/green). I've an example of the amchart in their online Chart maker https://live.amcharts.com/new/edit/. But I'm not able to get this working in icCube.
current we have icCube reporting version 7.0.0 (5549).
This is my chart JSON:
{
"box": {
"id": "wb695",
"widgetAdapterId": "w28",
"rectangle": {
"left": 1510,
"top": 340,
"right": 1910,
"bottom": 640
},
"zIndex": 901
},
"data": {
"mode": "MDX",
"schemaSettings": {
"cubeName": null,
"schemaName": null
},
"options": {
"WIZARD": {
"measures": [],
"rows": [],
"rowsNonEmpty": false,
"columns": [],
"columnsNonEmpty": false,
"filter": []
},
"MDX": {
"statement": "with \n member [Measures].[Measure1] AS 0.9\n member [Measures].[Measure2] AS 0.1\nSELECT\n\n{[Measures].[Measure1], [Measures].[Measure2]} on 0\n\nFROM [cube]"
},
"DATASOURCE": {}
},
"ic3_name": "mdx Query-5",
"ic3_uid": "m17"
},
"data-render": {
"chartType": {
"label": "Gauge",
"proto": {
"chartPrototype": {
"type": "gauge",
"arrows": [
{
"id": "GaugeArrow-1"
}
],
"axes": [
{
"id": "GaugeAxis-1"
}
]
},
"graphPrototype": {},
"dataProviderType": 3
},
"id": "gauge-chart"
},
"graphsConfiguration": [
{
"graph": {}
}
],
"valueAxes": [],
"trendLinesGuides": {},
"configuredQuadrants": {},
"advanced": {
"titles": [],
"faceAlpha": 0,
"faceBorderAlpha": 0
},
"balloon": {
"offsetX": 8
},
"chartOptions": {
"axes": [
{
"axisAlpha": 0.25,
"bottomText": "SLA",
"bottomTextColor": "#2A3F56",
"tickAlpha": 0.25,
"bandOutlineAlpha": 1,
"bandAlpha": 1,
"bandOutlineThickness": 95,
"bandOutlineColor": "#0095BC",
"id": 1
}
],
"bands": [
{
"alpha": 0.8,
"color": "#B53728",
"endValue": 0.6,
"startValue": 0,
"id": "GaugeBand-1"
},
{
"alpha": 0.6,
"color": "#435035",
"endValue": 1,
"startValue": 0.6,
"innerRadius": 0.69,
"id": "GaugeBand-2"
}
]
},
"ic3Data": {
"chartTypeConfig": {
"pie-chart-donut": {
"chartType": {
"label": "Donut",
"proto": {
"chartPrototype": {
"type": "donut",
"pullOutRadius": 0,
"startDuration": 0,
"legend": {
"enabled": false,
"align": "center",
"markerType": "circle"
},
"innerRadius": "60%"
},
"dataProviderType": 1
},
"id": "pie-chart-donut"
},
"graphsConfiguration": [
{}
],
"valueAxes": [],
"trendLinesGuides": {},
"configuredQuadrants": {},
"advanced": {
"titles": []
},
"balloon": {
"offsetX": 8
},
"chartOptions": {
"showZeroSlices": false,
"labelsEnabled": false,
"innerRadius": "60%",
"startAngle": 270,
"radius": "",
"fontSize": 20,
"color": "#0095BC",
"outlineAlpha": 0.25,
"tapToActivate": false
}
}
}
},
"axes": [
{
"startValue": 0,
"endValue": 1,
"startAngle": -90,
"endAngle": 90
}
],
"valueFormatting": ""
},
"navigation": {
"menuVisibility": {
"back": true,
"axisXChange": "All",
"axisYChange": "All",
"filter": "All",
"reset": true,
"widget": true,
"others": "All"
},
"selectionMode": "disabled"
},
"events": {},
"filtering": {},
"hooks": {}
}
Sorry for the late answer, out of the box it's not possible but you can use hooks to change the javascript options sent to amcharts.
JS / On Widget Options :
function(context, options, $box) {
const bands = [
{
"color": "#00CC00",
"endValue": 300000,
"id": "GaugeBand-1",
"startValue": 0
},
{
"color": "#ffac29",
"endValue": 600000,
"id": "GaugeBand-2",
"startValue": 300000
},
{
"color": "#ea3838",
"endValue": 900000,
"id": "GaugeBand-3",
"innerRadius": "95%",
"startValue": 600000
}
];
options.axes[0]["bands"] = bands;
return options;
}
This should work

Is there a minimum confidence for celebrity detection in microsoft cognitive services api?

All the confidences I've seen for celebrity detection has been very high. Is there some minimum confidence threshold for which the API will not consider a celebrity present?
The API will return an empty or null "celebrities" JSON array if it doesn't recognize a celebrity and will only return a populated "celebrities" JSON array if the "confidence" level is above 0.
Here's an examples running 2 pictures of Michael Jackson through the celebrities and landmarks section in the Computer Vision API page:
Michael Jackson is recognized and a populated "celebrities" JSON array is returned
{
"categories": [
{
"name": "people_portrait",
"score": 0.62109375,
"detail": {
"celebrities": [
{
"name": "Michael Jackson",
"faceRectangle": {
"left": 377,
"top": 282,
"width": 381,
"height": 381
},
"confidence": 0.99902832508087158
}
],
"landmarks": null
}
}
],
"adult": null,
"tags": [
{
"name": "person",
"confidence": 0.99581664800643921
}
],
"description": {
"tags": [
"person",
"man",
"young",
"standing",
"looking",
"front",
"holding",
"wearing",
"shirt",
"posing",
"boy",
"white",
"smiling",
"dark",
"black",
"table",
"large",
"suit",
"woman",
"board"
],
"captions": [
{
"text": "Michael Jackson posing for the camera",
"confidence": 0.91584373926593021
}
]
},
"requestId": "ac41aa84-9a70-4ffc-8de4-5a662600fc56",
"metadata": {
"width": 1000,
"height": 1000,
"format": "Jpeg"
},
"faces": [
{
"age": 31,
"gender": "Male",
"faceRectangle": {
"left": 377,
"top": 282,
"width": 381,
"height": 381
}
}
],
"color": {
"dominantColorForeground": "White",
"dominantColorBackground": "Black",
"dominantColors": [
"Black",
"White"
],
"accentColor": "B64215",
"isBWImg": false
},
"imageType": {
"clipArtType": 0,
"lineDrawingType": 0
}
}
Michael Jackson is not recognized and an empty "celebrities" JSON array is returned
{
"categories": [
{
"name": "people_",
"score": 0.94140625,
"detail": {
"celebrities": [],
"landmarks": null
}
}
],
"adult": null,
"tags": [
{
"name": "person",
"confidence": 0.99912232160568237
},
{
"name": "outdoor",
"confidence": 0.936089813709259
}
],
"description": {
"tags": [
"person",
"outdoor",
"man",
"woman",
"standing",
"front",
"suit",
"holding",
"car",
"wearing",
"people",
"couple",
"posing",
"young",
"bus",
"black",
"smiling",
"glasses",
"umbrella",
"group",
"table",
"city",
"red",
"water",
"street",
"phone",
"boat",
"train"
],
"captions": [
{
"text": "a couple of people posing for the camera",
"confidence": 0.86922603629725859
}
]
},
"requestId": "7d57493c-f8b0-468f-8135-17da555d2463",
"metadata": {
"width": 1000,
"height": 1000,
"format": "Jpeg"
},
"faces": [
{
"age": 38,
"gender": "Female",
"faceRectangle": {
"left": 400,
"top": 270,
"width": 234,
"height": 234
}
}
],
"color": {
"dominantColorForeground": "Black",
"dominantColorBackground": "Black",
"dominantColors": [
"Black",
"Grey"
],
"accentColor": "364E5D",
"isBWImg": false
},
"imageType": {
"clipArtType": 0,
"lineDrawingType": 0
}
}

Fetching "Special Hours" from Google Business

A Place Details response using the Google Places API only includes normal operating hours, not special hours. When you “download all locations” from the Google Business UI in CSV format, there is a row titled “special hours” with the data I want to retrieve. So I know it's there. See an example of this at the following published Google Sheet:
https://docs.google.com/spreadsheets/d/e/2PACX-1vR9lrELXbbiDw9QLeVEo-Ob6JH2hf5YuI2vRjQ9mPASMFfiXlLKPUSf98GkjN87h--y2f7DgVx0lFhE/pubhtml
Is it possible to retrieve “Special Hours” information from Google Business using the Google Places API Web Service or is this only possible by using the Google Business API?
A parameter titled "special hours" exists in the Google Business API Documentation.
//JSON example for a Place Details Response using Google Places API Web service
{
"html_attributions" : [],
"result" : {
"address_components" : [
{
"long_name" : "San Luis Obispo",
"short_name" : "San Luis Obispo",
"types" : [ "locality", "political" ]
},
{
"long_name" : "San Luis Obispo County",
"short_name" : "San Luis Obispo County",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "California",
"short_name" : "CA",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
},
{
"long_name" : "93407",
"short_name" : "93407",
"types" : [ "postal_code" ]
}
],
"adr_address" : "Building 65, 1 Grande Ave, \u003cspan class=\"street-address\"\u003eCalifornia Polytechnic State University\u003c/span\u003e, \u003cspan class=\"locality\"\u003eSan Luis Obispo\u003c/span\u003e, \u003cspan class=\"region\"\u003eCA\u003c/span\u003e \u003cspan class=\"postal-code\"\u003e93407\u003c/span\u003e, \u003cspan class=\"country-name\"\u003eUSA\u003c/span\u003e",
"formatted_address" : "Building 65, 1 Grande Ave, California Polytechnic State University, San Luis Obispo, CA 93407, USA",
"formatted_phone_number" : "(805) 756-4089",
"geometry" : {
"location" : {
"lat" : 35.30001179999999,
"lng" : -120.6586874
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id" : "f70e2b28dda6dbf04550b76db802f20fe1f79d5c",
"international_phone_number" : "+1 805-756-4089",
"name" : "Mustang Station",
"opening_hours" : {
"open_now" : false,
"periods" : [
{
"close" : {
"day" : 0,
"time" : "2300"
},
"open" : {
"day" : 0,
"time" : "1030"
}
},
{
"close" : {
"day" : 1,
"time" : "2300"
},
"open" : {
"day" : 1,
"time" : "1030"
}
},
{
"close" : {
"day" : 2,
"time" : "2300"
},
"open" : {
"day" : 2,
"time" : "1030"
}
},
{
"close" : {
"day" : 3,
"time" : "2300"
},
"open" : {
"day" : 3,
"time" : "1030"
}
},
{
"close" : {
"day" : 4,
"time" : "2300"
},
"open" : {
"day" : 4,
"time" : "1030"
}
},
{
"close" : {
"day" : 6,
"time" : "0000"
},
"open" : {
"day" : 5,
"time" : "1030"
}
},
{
"close" : {
"day" : 0,
"time" : "0000"
},
"open" : {
"day" : 6,
"time" : "1030"
}
}
],
"weekday_text" : [
"Monday: 10:30 AM – 11:00 PM",
"Tuesday: 10:30 AM – 11:00 PM",
"Wednesday: 10:30 AM – 11:00 PM",
"Thursday: 10:30 AM – 11:00 PM",
"Friday: 10:30 AM – 12:00 AM",
"Saturday: 10:30 AM – 12:00 AM",
"Sunday: 10:30 AM – 11:00 PM"
]
},
"photos" : [
{
"height" : 2340,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/112622063888784238324/photos\"\u003eJana Isabel Gervacio\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAGZsi0QehA7q1gTjAThJgTUtDSkkGaL4Xk_x01RkN6t8HfoABoLGl45Gpo_bznS4sI4OKag40IWiCsbq8J-naZ-9YwQ4iZ9H1YrFEBTMdlTWoxnW0uxpABT-2JKn6D7q38yQP5lznOlL7RmghoNxwbSvB6TDk45iwDLMSce-JBPcEhDLAcpTdUku3To8HxDhhszlGhRwBi5muKEn_68_MOAnjx0MLbSBJw",
"width" : 4160
},
{
"height" : 3840,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110980259514072024035/photos\"\u003eMustang Station\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAB0VKDa1mNnEVRpWtjg8lbM3zONoyqai_LmUB41fP7FtprCairVIzw_QBpKix4ZNOn6swUgNf8C907X0bv8SnMktdacFV_aSy6sOFogdRPveXCBx84p2wrVH95GwTpk0lsNhzLovPuk9oZ39nH1U7XdP3LUfdNWQL2XCgUBqlkICEhDqaRdvjIG9gdp5gUWVfSAMGhRG75JyhhhqUxyZAU62IP_z-oMj7A",
"width" : 5760
},
{
"height" : 3456,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110980259514072024035/photos\"\u003eMustang Station\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAEb9o0hItdL5eswLOgmJH9EOGNlqfWbjkcwhv9Aqk9yPbqAIhrTkeyun9r-G38kxcpO7QW3hD_MNtik07JAFhY2oY4fXuEeE1pKeAq7faNNytgQDCG37vh_LRqAVEaHa0bIAS22WKMFtOIquAviLkOyNQyT0_DCUXkd2E53OcRqdEhDfUVSCKsC1CHsMPAKv6VjNGhR6wXUF07Xe7KuZ52G1s_tCdGCG6Q",
"width" : 5184
},
{
"height" : 3840,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110980259514072024035/photos\"\u003eMustang Station\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAHDbQqs7ehYjfkyARQxQq2PVWnIN6z6Enju8bnTmqUq4_UgDeAigezxyhv4b8QC7tT1F0O-OJuqZbhAqyTlXB1OYO_k0_Y7mk1114ah-BG8PUd84KnRD3CXh7G3wducvWrXtNZkFua-CoFdQG_q8050wUDST5tCWA1VeDvNjkw8pEhDs9E0GxCooxR0A6nn0_BkVGhT3Ub9zxr1PGVQFRV_TecWKzZmiYg",
"width" : 5760
},
{
"height" : 3456,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110980259514072024035/photos\"\u003eMustang Station\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAP9OkyME0q72GrHkLPkjMoaauPmsYhZBD8wH1qBL_JAEGV8Dhz_6HJcUN_Y64ycfkKzk10COR52XmLerELpEYuxAYG3NHUcfF7Yq0GzEaFcNPIRWa4WgSsnAX5y16im6bvF_KZbW5iuDyX4ET6RW6bgTBwVH-zjAlZYmCI5GXpJ0EhDErfuy0lpX8LKAe8ipjC-BGhQqpZa7Y53HQBQvuIH37jORLeD0hQ",
"width" : 5184
},
{
"height" : 3840,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110980259514072024035/photos\"\u003eMustang Station\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAEWy_E_dGD3N1ChEdeAzZoNP9mU0JhPEZY4QWf1I0XO73PWM8vmrTA0JjHFsm_qCf6XAmiVgJxPQTNtGTHwYghq7NL91bGYOEIvOLYl5iwxP_RC96zn5hCZnwwp1s4xkzouawNKp0oSCzwpfpUgCQrpplf35QLc1xGj3wsMbTcAbEhCUztajO_mhA0BLHk90mDxSGhRKOzWwFMx7Uhxvqh4afBaKSa6S9g",
"width" : 5760
},
{
"height" : 3000,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/116558159141762616471/photos\"\u003ePatrick Chea\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAGWjbZD71nwtfSTA3rRg93F-c_-EyicXxxA8vQ8DSX9hsvDOOCxy8gNUhXF5rDyShtcTm8Gh5qiCGg3xSvA5LDbJiXs7IpGAwAoVTb7_-d4DlNBX0jmkb8tGWdYNkqMo9jTtLr50BY9emgIljAHDaTBrzKlcrgi3Q2rSJM-WnUhaEhC4SwcYYd4Ce2upxRjP8taRGhSsvzcpFjR60jxDLxRlKzhgRIVzWA",
"width" : 4000
},
{
"height" : 800,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110980259514072024035/photos\"\u003eMustang Station\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAEu4y0vjM28hn4yFnPz1qWQ0iYysDRPNfY0DiTHlmWMhLI1RfFlWctexo-Gw4iM51yDXo1f2C4eOvN5Gh50ZFfOsfuaLBptwzNYdm9wdBt6Hd5JjiUuEWlVLXo4pKz_62v3ohS2OZfdTJ6Wz5Fw44gVYyA_m9nX3fSCuPp8O2MkMEhCJVvjZOZouIyfIDKFkdg4XGhR8Tgj_y6Tibv548tyMmF5pjB_4VA",
"width" : 800
},
{
"height" : 3456,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110980259514072024035/photos\"\u003eMustang Station\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAFG2hBYdpnJYG9DjvY1dnAus3YG89BeKGFx8--e0fwq8OPzCvbQVrXkyiB91KkjnMg8Oum11B4-fHVy6PkuXkat-T9r30PjKNs5KQJTYBWZ-U1SvdQoRx4auOdLzrgNNknVYtUD0fnf6L6MyaJajCvuRJxkd5fhmpM0-qYpwwp24EhCAm-eSSO2TX8lQYa1Vkl41GhR82nfX24T7EoP-xSVKjR-RV5KXYQ",
"width" : 3456
},
{
"height" : 5184,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110980259514072024035/photos\"\u003eMustang Station\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAALUHiKRI96TGd_7wEGmKlvU2j5WcWVl9B0jYBMBJsHyQLHHTROslXcW9dFTi_7aAK_yTcXOTwMoXJye301W6utyysncbDgPMfOru9YC5BTLpFOSpmpQButZ9Iw75MM8jgf5G-FWEtpnCSRSIAaTCg4yPpJWzdVMZyeFxOn7-wx7-EhAYF5iL9wN3hfqccpCq7DivGhR8mRQFqoyXjq6eUuaCLD2RUMj9LQ",
"width" : 3456
}
],
"place_id" : "ChIJi3n5orHx7IARQrPTx81AfZU",
"reference" : "CmRSAAAAwt8fxPAzOX-uQm83_KDcR1Yic89fu-ykEcK2vAJCKS6j1f4_KVCrhoOfQAX8bQd_vXS-k8fEhCQud8JjIhXZBYuIeq3UBfoxhf9zOClHJRi5pstBA21a_FTxP8eyXJ1bEhAMXM_iW_ZlS0LkpOss-b0bGhTVYEqAJEUmeSMUM41wf-1gUBKhCw",
"reviews" : [
{
"aspects" : [
{
"rating" : 2,
"type" : "overall"
}
],
"author_name" : "Spencer Shaw",
"author_url" : "https://www.google.com/maps/contrib/104561547095341505444/reviews",
"language" : "en",
"rating" : 4,
"text" : "",
"time" : 1476463293
},
{
"aspects" : [
{
"rating" : 3,
"type" : "overall"
}
],
"author_name" : "Joseph Pack",
"author_url" : "https://www.google.com/maps/contrib/105745544693109977233/reviews",
"language" : "en",
"profile_photo_url" : "//lh6.googleusercontent.com/-HJVfdTf8Kf0/AAAAAAAAAAI/AAAAAAAABo8/y8qAcuE4h7c/photo.jpg",
"rating" : 5,
"text" : "",
"time" : 1474354270
},
{
"aspects" : [
{
"rating" : 1,
"type" : "overall"
}
],
"author_name" : "Erik Sandberg",
"author_url" : "https://www.google.com/maps/contrib/113791312001095793561/reviews",
"language" : "en",
"profile_photo_url" : "//lh6.googleusercontent.com/-DH91vW9zE6U/AAAAAAAAAAI/AAAAAAAAKiA/Xi3IaYgtIr4/photo.jpg",
"rating" : 3,
"text" : "",
"time" : 1448072416
}
],
"scope" : "GOOGLE",
"types" : [ "restaurant", "food", "point_of_interest", "establishment" ],
"url" : "https://maps.google.com/?cid=10771837136305107778",
"utc_offset" : -480,
"vicinity" : "Building 65, 1 Grande Ave, California Polytechnic State University, San Luis Obispo",
"website" : "https://www.calpolydining.com/mustangstation/"
},
"status" : "OK"
}
There is a feature request in the public issue tracker to add Special Hours in the Places details response:
https://code.google.com/p/gmaps-api-issues/issues/detail?id=10145
It looks like Google created a corresponding internal issue #30233280 and is evaluating the feasibility to implement this.
Please star the feature request in the public issue tracker to express your interest and receive updates from Google.