How to get Cities from Geo Data - python-3.x

I have some data about automobiles(particularly Transport Trucks). The Data includes Time , Latitude and Longitude of the vehicles among other things.
En Example Would Be:
Latitude Longitude UTC
19.250463 73.042856 2018-12-01 00:02:19
19.249853 73.043862 2018-12-01 00:04:12
19.24953 73.043923 2018-12-01 00:04:41
19.249527 73.043938 2018-12-01 00:09:12
19.249457 73.044172 2018-12-01 00:14:12
19.249484 73.044128 2018-12-01 00:19:12
There is a lot of data. The problem i am facing right now is to find the various 'Cities visited by this certain vehicle.
Here is a plot of Latitude and Longitude:
Here I have added the number of points within a 20KM radius of each point as a feature in the data. Then I have applied DBSCAN on these three features and represented the classes as colors.
As you can see, It fails to recognize the 'Intersection' points. Ideally i need a way to find corners, endpoints in this data.
Having a predefined list of cities along with their locations is not an option, because the general are of these trucks can vary greatly and then can visit small towns as well.

There are a couple of ways that you can solve this problem. The first, which would probably be the most performant, would be to build the inverse geocoding database yourself using information provided here: http://download.geonames.org/export/dump/
Of course this information would then have to be kept up to date which could be a pain.
If you're okay with a bit of latency, there are also third party services that do this for you. I run one of these third party services called https://geo-info.co/
You'd be able to solve this problem very easily with this API. For example
https://geo-info.co/19.250463,73.042856
Which would return the city along with some other info such as nearby locations.
{
"city": "Vishnunagar",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.267",
"longitude": "73.0715",
"nearby": [
{
"city": "Dombivali I.A.",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.267",
"longitude": "73.0715",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421203"
},
{
"city": "Dombivali",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.2167",
"longitude": "73.0833",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421201"
},
{
"city": "Ramnagar (Thane)",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.2167",
"longitude": "73.0833",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421201"
},
{
"city": "Thakurli",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.2167",
"longitude": "73.0833",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421201"
},
{
"city": "Tilaknagar (Thane)",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.2167",
"longitude": "73.0833",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421201"
},
{
"city": "Bhiwandi",
"community": "Bhiwandi",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.3002",
"longitude": "73.0588",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421308"
},
{
"city": "Khoni",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.3173",
"longitude": "73.0597",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421204"
},
{
"city": "Manpada",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.3173",
"longitude": "73.0597",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421204"
},
{
"city": "Nilje",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.3173",
"longitude": "73.0597",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421204"
},
{
"city": "Padle",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.3173",
"longitude": "73.0597",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421204"
}
],
"state": "Maharashtra",
"state2": "16",
"zipcode": "421202"
}

Related

groovy:LinkedHash: missing property

I'm struggling to remove key 'customerNumber' from sub-arrays allAddresses and allPersons. my requirement is that in the below payload key customerNumber should only appear in the parent array CustomerMaster. all other appearances of customerNumber should be deleted.
with the below code I get error groovy.lang.MissingPropertyException: No such property: allAddresses for class: java.util.LinkedHashMap$Entry. To my surprise the code works when the key CustomerMaster is an array. I dont understand why it fails if the customer is not an array
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.json.JsonSlurper;
import groovy.json.JsonOutput;
import groovy.json.*
def Message removeCustomerNumber(Message message) {
def body = message.getBody(String)
//def body = message.getBody(String.class);
body=body.toString();
def json = new JsonSlurper().parseText(body)
json.CustomerMaster.each{
// if (it.allAddresses.metaClass.respondsTo('each')){
// if(it.metaClass.hasProperty(it, 'allAddresses')){
it.allAddresses.each{
it.remove('customerNumber')
}
// }
// }
}
def out= JsonOutput.toJson(json);
//out = JsonOutput.prettyPrint()
message.setBody(out);
return message;
}
in other words when the CustomerMaster is an collection, I have no issue. I tried checking with hasProperty() and respondsTo() with out success
payload:
{
"CustomerMaster": {
"activitySector": "01",
"cognosCode": "ES001",
"companyName1": "SANIPLAST SOL. SOSTEN. DEL AGUA SL",
"companyName2": "ALIAXIS IBERIA S.A.U.",
"creditControlArea": "ES01",
"currency": "EUR",
"customerNumber": "0000100001",
"allPersons": [
{
"birthday": "00000000",
"cognosCode": "ES001",
"contactId": "0000000308",
"customerNumber": "0000100001",
"jobTitle": "ENCARGADO COBROS",
"language": "ES",
"lastName": "EDUARDO JIMENEZ"
},
{
"birthday": "20210419",
"cognosCode": "ES001",
"contactId": "0000000475",
"customerNumber": "0000100001",
"email1": "FACTURASPDF.SNPT#ABAST.ES",
"jobTitle": "ENVÍO FACTURACIÓN",
"language": "ES",
"lastName": "FACTURACION"
},
{
"birthday": "00000000",
"cognosCode": "ES001",
"contactId": "0000000036",
"customerNumber": "0000100001",
"jobTitle": "REPRESENTANTE LEGAL",
"language": "ES",
"lastName": "D. JULIO ESTEBAN SALGADO"
}
],
"allAddresses": [
{
"StateOrProvince": "MERES-SIERO",
"city": "MERES-SIERO",
"countryCode": "ES",
"customerNumber": "0000100001",
"fax": "985793802",
"id": "0000372156",
"name": "SANIPLAST SOL. SOSTEN. DEL AGUA SL",
"number": "1",
"phoneBusiness": "985-792224",
"postalCode": "33199",
"region": "33",
"street": "POL.IND.PRONI. CALLE D",
"type": "WE"
},
{
"StateOrProvince": "MERES-SIERO",
"city": "MERES-SIERO",
"countryCode": "ES",
"customerNumber": "0000100001",
"fax": "985793802",
"id": "0000372156",
"name": "SANIPLAST SOL. SOSTEN. DEL AGUA SL",
"number": "1",
"phoneBusiness": "985-792224",
"postalCode": "33199",
"region": "33",
"street": "POL.IND.PRONI. CALLE D",
"type": "AG"
},
{
"StateOrProvince": "MERES-SIERO",
"city": "MERES-SIERO",
"countryCode": "ES",
"customerNumber": "0000100001",
"fax": "985793802",
"id": "0000372156",
"name": "SANIPLAST SOL. SOSTEN. DEL AGUA SL",
"number": "1",
"phoneBusiness": "985-792224",
"postalCode": "33199",
"region": "33",
"street": "POL.IND.PRONI. CALLE D",
"type": "RE"
},
{
"StateOrProvince": "MERES-SIERO",
"city": "MERES-SIERO",
"countryCode": "ES",
"customerNumber": "0000100001",
"fax": "985793802",
"id": "0000372156",
"name": "SANIPLAST SOL. SOSTEN. DEL AGUA SL",
"number": "1",
"phoneBusiness": "985-792224",
"postalCode": "33199",
"region": "33",
"street": "POL.IND.PRONI. CALLE D",
"type": "RG"
},
{
"StateOrProvince": "MERES-SIERO",
"city": "MERES-SIERO",
"countryCode": "ES",
"customerNumber": "0000100001",
"fax": "985793802",
"id": "0000372156",
"name": "SANIPLAST SOL. SOSTEN. DEL AGUA SL",
"number": "1",
"phoneBusiness": "985-792224",
"postalCode": "33199",
"region": "33",
"street": "POL.IND.PRONI. CALLE D",
"type": "ZV"
}
],
"email1": "JUANJOSE.GONZALEZ#SANIPLAST.ES",
"entityCode": "ES01",
"fax": "985793802",
"phone1": "985-792224",
"phone2": "985791154ISABEL",
"termsofPayment": "Z037"
}
}
def json = new JsonSlurper().parseText(body)
if(json.CustomerMaster instanceof List){
json.CustomerMaster.each{
it.allPersons?.each{it.remove("customerNumber")}
it.allAddresses?.each{it.remove("customerNumber")}
}
}else{
json.CustomerMaster?.allPersons?.each{it.remove("customerNumber")}
json.CustomerMaster?.allAddresses?.each{it.remove("customerNumber")}
}
with ternary operator
( json.CustomerMaster instanceof List ? json.CustomerMaster : [json.CustomerMaster] ).each{
it?.allPersons?.each{it.remove("customerNumber")}
it?.allAddresses?.each{it.remove("customerNumber")}
}

How to solve mongodb aggregate lookup returning result of all foreign-field in one local-field before opening the other once

I've searched the internet and StackOverflow, but I cannot find the answer or even the question.
I have two collections, artisan and users. I want my query to return all reports and indicate if the specified user has that report as a favorite in their array.
I'm finding hard to remove the other result for the next data that is set in the first result.
i would love to receive some help on how to get the correct value from the aggregate statement.
if you look so closely, you will see that "_id": "5f21f998fe054d2cf0b7f787" is showing 3 times, but the correct one is the one with "user_id": "5f21f998fe054d2cf0b7f787" of artisan. That is the same for others also
Here below is the code and the result i was getting
Thanks
User.aggregate([
{
$lookup: {
from: Artisan.collection.name,
localField: "user._id",
foreignField: "artisan.user_id",
as: "artisan"
}
},
{$unwind: '$artisan'}
])
.then((result) => {
res.json(result);
}, (err) => next(err))
.catch((err) => next(err));```
\\Here is the result
[
{
"_id": "5f21f998fe054d2cf0b7f787",
"email_verified": null,
"sex": "male",
"phone_no": 2348117741341,
"address": "10 Oweh Street",
"area": "",
"city": "Lagos",
"state": "Lagos",
"country": "",
"job_type": "great work",
"status": "",
"login_key": "",
"login_valid_till": null,
"firstname": "Johnson",
"othername": "Ayobami",
"lastname": "Eniola",
"email": "ekundayoolumide#gmail.com",
"password": "$2b$10$BlfwHzVgZ4kWYfG6Ia4x.Oj6cdVG24Cwl3R9FZQ9lK/1LoUg.WbAi",
"user_type": "artisan",
"createdAt": "2020-07-29T22:35:04.601Z",
"updatedAt": "2020-07-29T22:35:04.601Z",
"__v": 0,
"artisan": {
"_id": "5f21f998fe054d2cf0b7f788",
"date_of_birth": null,
"duration": "",
"payment_status": "",
"payment_type": "",
"user_id": "5f21f998fe054d2cf0b7f787",
"createdAt": "2020-07-29T22:35:04.645Z",
"updatedAt": "2020-07-29T22:35:04.645Z",
"__v": 0
}
},
{
"_id": "5f21f998fe054d2cf0b7f787",
"email_verified": null,
"sex": "male",
"phone_no": 2348117741341,
"address": "10 Oweh Street",
"area": "",
"city": "Lagos",
"state": "Lagos",
"country": "",
"job_type": "great work",
"status": "",
"login_key": "",
"login_valid_till": null,
"firstname": "Johnson",
"othername": "Ayobami",
"lastname": "Eniola",
"email": "ekundayoolumide#gmail.com",
"password": "$2b$10$BlfwHzVgZ4kWYfG6Ia4x.Oj6cdVG24Cwl3R9FZQ9lK/1LoUg.WbAi",
"user_type": "artisan",
"createdAt": "2020-07-29T22:35:04.601Z",
"updatedAt": "2020-07-29T22:35:04.601Z",
"__v": 0,
"artisan": {
"_id": "5f21fa632fc70100d0339194",
"date_of_birth": null,
"duration": "4 years",
"payment_status": "",
"payment_type": "",
"user_id": "5f21fa632fc70100d0339193",
"createdAt": "2020-07-29T22:38:27.998Z",
"updatedAt": "2020-07-29T22:42:22.601Z",
"__v": 0
}
},
{
"_id": "5f21f998fe054d2cf0b7f787",
"email_verified": null,
"sex": "male",
"phone_no": 2348117741341,
"address": "10 Oweh Street",
"area": "",
"city": "Lagos",
"state": "Lagos",
"country": "",
"job_type": "great work",
"status": "",
"login_key": "",
"login_valid_till": null,
"firstname": "Johnson",
"othername": "Ayobami",
"lastname": "Eniola",
"email": "ekundayoolumide#gmail.com",
"password": "$2b$10$BlfwHzVgZ4kWYfG6Ia4x.Oj6cdVG24Cwl3R9FZQ9lK/1LoUg.WbAi",
"user_type": "artisan",
"createdAt": "2020-07-29T22:35:04.601Z",
"updatedAt": "2020-07-29T22:35:04.601Z",
"__v": 0,
"artisan": {
"_id": "5f227b0433105d3a3864547e",
"date_of_birth": null,
"duration": "",
"payment_status": "",
"payment_type": "",
"user_id": "5f227b0433105d3a3864547d",
"createdAt": "2020-07-30T07:47:16.269Z",
"updatedAt": "2020-07-30T07:47:16.269Z",
"__v": 0
}
},
{
"_id": "5f21fa632fc70100d0339193",
"email_verified": null,
"sex": "male",
"phone_no": 2348117741341,
"address": "10 Oweh Street",
"area": "",
"city": "Lagos",
"state": "Lagos",
"country": "",
"job_type": "great work",
"status": "",
"login_key": "",
"login_valid_till": null,
"firstname": "Johnson",
"othername": "Akinmade",
"lastname": "Eniola",
"email": "ekundayoolumide1#gmail.com",
"password": "john1234",
"user_type": "artisan",
"createdAt": "2020-07-29T22:38:27.957Z",
"updatedAt": "2020-07-29T22:42:22.454Z",
"__v": 0,
"artisan": {
"_id": "5f21f998fe054d2cf0b7f788",
"date_of_birth": null,
"duration": "",
"payment_status": "",
"payment_type": "",
"user_id": "5f21f998fe054d2cf0b7f787",
"createdAt": "2020-07-29T22:35:04.645Z",
"updatedAt": "2020-07-29T22:35:04.645Z",
"__v": 0
}
},
{
"_id": "5f21fa632fc70100d0339193",
"email_verified": null,
"sex": "male",
"phone_no": 2348117741341,
"address": "10 Oweh Street",
"area": "",
"city": "Lagos",
"state": "Lagos",
"country": "",
"job_type": "great work",
"status": "",
"login_key": "",
"login_valid_till": null,
"firstname": "Johnson",
"othername": "Akinmade",
"lastname": "Eniola",
"email": "ekundayoolumide1#gmail.com",
"password": "john1234",
"user_type": "artisan",
"createdAt": "2020-07-29T22:38:27.957Z",
"updatedAt": "2020-07-29T22:42:22.454Z",
"__v": 0,
"artisan": {
"_id": "5f21fa632fc70100d0339194",
"date_of_birth": null,
"duration": "4 years",
"payment_status": "",
"payment_type": "",
"user_id": "5f21fa632fc70100d0339193",
"createdAt": "2020-07-29T22:38:27.998Z",
"updatedAt": "2020-07-29T22:42:22.601Z",
"__v": 0
}
},
{
"_id": "5f21fa632fc70100d0339193",
"email_verified": null,
"sex": "male",
"phone_no": 2348117741341,
"address": "10 Oweh Street",
"area": "",
"city": "Lagos",
"state": "Lagos",
"country": "",
"job_type": "great work",
"status": "",
"login_key": "",
"login_valid_till": null,
"firstname": "Johnson",
"othername": "Akinmade",
"lastname": "Eniola",
"email": "ekundayoolumide1#gmail.com",
"password": "john1234",
"user_type": "artisan",
"createdAt": "2020-07-29T22:38:27.957Z",
"updatedAt": "2020-07-29T22:42:22.454Z",
"__v": 0,
"artisan": {
"_id": "5f227b0433105d3a3864547e",
"date_of_birth": null,
"duration": "",
"payment_status": "",
"payment_type": "",
"user_id": "5f227b0433105d3a3864547d",
"createdAt": "2020-07-30T07:47:16.269Z",
"updatedAt": "2020-07-30T07:47:16.269Z",
"__v": 0
}
},
{
"_id": "5f227b0433105d3a3864547d",
"email_verified": null,
"sex": "male",
"phone_no": 2348117741341,
"address": "10 Oweh Street",
"area": "",
"city": "Lagos",
"state": "Lagos",
"country": "",
"job_type": "great work",
"status": "",
"login_key": "",
"login_valid_till": null,
"firstname": "Johnson",
"othername": "Akinmade",
"lastname": "Eniola",
"email": "ekundayoolumide2#gmail.com",
"password": "$2b$10$jg/nKNpg/RkDA.KFG/flFuy8fwfamLdgCD7MNk16rprDiwoWTKcse",
"user_type": "artisan",
"createdAt": "2020-07-30T07:47:16.234Z",
"updatedAt": "2020-07-30T07:47:16.234Z",
"__v": 0,
"artisan": {
"_id": "5f21f998fe054d2cf0b7f788",
"date_of_birth": null,
"duration": "",
"payment_status": "",
"payment_type": "",
"user_id": "5f21f998fe054d2cf0b7f787",
"createdAt": "2020-07-29T22:35:04.645Z",
"updatedAt": "2020-07-29T22:35:04.645Z",
"__v": 0
}
},
{
"_id": "5f227b0433105d3a3864547d",
"email_verified": null,
"sex": "male",
"phone_no": 2348117741341,
"address": "10 Oweh Street",
"area": "",
"city": "Lagos",
"state": "Lagos",
"country": "",
"job_type": "great work",
"status": "",
"login_key": "",
"login_valid_till": null,
"firstname": "Johnson",
"othername": "Akinmade",
"lastname": "Eniola",
"email": "ekundayoolumide2#gmail.com",
"password": "$2b$10$jg/nKNpg/RkDA.KFG/flFuy8fwfamLdgCD7MNk16rprDiwoWTKcse",
"user_type": "artisan",
"createdAt": "2020-07-30T07:47:16.234Z",
"updatedAt": "2020-07-30T07:47:16.234Z",
"__v": 0,
"artisan": {
"_id": "5f21fa632fc70100d0339194",
"date_of_birth": null,
"duration": "4 years",
"payment_status": "",
"payment_type": "",
"user_id": "5f21fa632fc70100d0339193",
"createdAt": "2020-07-29T22:38:27.998Z",
"updatedAt": "2020-07-29T22:42:22.601Z",
"__v": 0
}
},
{
"_id": "5f227b0433105d3a3864547d",
"email_verified": null,
"sex": "male",
"phone_no": 2348117741341,
"address": "10 Oweh Street",
"area": "",
"city": "Lagos",
"state": "Lagos",
"country": "",
"job_type": "great work",
"status": "",
"login_key": "",
"login_valid_till": null,
"firstname": "Johnson",
"othername": "Akinmade",
"lastname": "Eniola",
"email": "ekundayoolumide2#gmail.com",
"password": "$2b$10$jg/nKNpg/RkDA.KFG/flFuy8fwfamLdgCD7MNk16rprDiwoWTKcse",
"user_type": "artisan",
"createdAt": "2020-07-30T07:47:16.234Z",
"updatedAt": "2020-07-30T07:47:16.234Z",
"__v": 0,
"artisan": {
"_id": "5f227b0433105d3a3864547e",
"date_of_birth": null,
"duration": "",
"payment_status": "",
"payment_type": "",
"user_id": "5f227b0433105d3a3864547d",
"createdAt": "2020-07-30T07:47:16.269Z",
"updatedAt": "2020-07-30T07:47:16.269Z",
"__v": 0
}
}
]
Right now you have:
$lookup: {
from: Artisan.collection.name,
localField: "user._id",
foreignField: "artisan.user_id",
as: "artisan"
}
After looking at your results, the documents from the User collection don't have a field named user._id, they just have an _id field. Similarly with your Artisan collection there isn't a field named artist.user_id, there's just a user_id field. Change the localField and foreignField values to only have the name of the fields as they appear in the respective documents.
It should look something like this:
$lookup: {
from: Artisan.collection.name,
localField: "_id",
foreignField: "user_id",
as: "artisan"
}

Issues in Adaptive card design in Microsoft bot framework

We are using Microsoft bot framework V3 and typescript and while designing Adaptive cards design below issues are facing
1.Card rendering is failing at UI side When we use "width": "80px" or width:1 for alignment.
Red color is not properly displaying("color": "Attention") whichi is coming as brick red
{
'contentType': 'application/vnd.microsoft.card.adaptive',
'content': {
'$schema': 'http://adaptivecards.io/schemas/adaptive-card.json',
'type': 'AdaptiveCard',
'version': '1.0',
'body': [
{
"type": "ColumnSet",
"separator": true,
"columns": [
{
"type": "Column",
"style": "emphasis",
"items": [
{
"type": "TextBlock",
"horizontalAlignment": "Left",
"spacing": "Small",
"size": "Small",
"color": "Dark",
"text": "Company",
"isSubtle": true,
"wrap": true
},
{
"type": "TextBlock",
"horizontalAlignment": "Left",
"spacing": "Small",
"size": "Small",
"color": "Dark",
"text": "PO Number",
"isSubtle": true,
"wrap": true
},
{
"type": "TextBlock",
"horizontalAlignment": "Left",
"spacing": "Small",
"size": "Small",
"color": "Dark",
"text": "Status",
"isSubtle": true,
"wrap": true
}
],
"width": "80px"
},
{
"type": "Column",
"style": "emphasis",
"items": [
{
"type": "TextBlock",
"horizontalAlignment": "Left",
"spacing": "Small",
"size": "Small",
"weight": "Bolder",
"text": "ABC.COM",
"wrap": true
},
{
"type": "TextBlock",
"horizontalAlignment": "Left",
"spacing": "Small",
"size": "Small",
"weight": "Bolder",
"text": "200123456",
"wrap": true
},
{
"type": "TextBlock",
"horizontalAlignment": "Left",
"spacing": "Small",
"size": "Small",
"weight": "Bolder",
"text": "canceled",
"wrap": true,
"color": "Attention"
}
],
"width": "stretch"
}
]
}
]
}
};

Parse large datasets and notify users efficiently

I have a huge dataset that increases by hundreds/thousands items for sale every few minutes. I will be parsing this data as it comes in and I'm looking for suggestions on how to efficiently match new incoming items with users who want the item.
Examples of how other have done this would mean the world to me. Even just clarification on what to search for online would be helpful. I'm having difficulty asking the right questions to search engines so I can learn how to solve this (usually I'm very good at this sort of thing).
Thank you fellow geniuses!
p.s. Hoping so solve this problem with nodejs
Inventory Dataset Example:
{
"anchor": 982179125,
"next_page": 1,
"next_tier": 0,
"num_matches": 47037,
"postings": [
{
"category": "SBIK",
"category_group": "SSSS",
"external_id": "4488716340",
"heading": "60cm Aluminum/Carbon Road Bike, Ultegra/105 equipped, 20-Spd",
"location": {
"accuracy": 8,
"city": "USA-SFO-SNF",
"country": "USA",
"county": "USA-CA-SAF",
"geolocation_status": 3,
"lat": "37.801041",
"locality": "USA-SFO-MRS",
"long": "-122.434151",
"metro": "USA-SFO",
"region": "USA-SFO-SAF",
"state": "USA-CA",
"zipcode": "USA-94123"
},
"price": 800.0
},
{
"category": "SBOT",
"category_group": "SSSS",
"external_id": "4488164318",
"heading": "Burley Bee Boat Trailer",
"location": {
"accuracy": 8,
"city": "USA-SFO-SNF",
"country": "USA",
"county": "USA-CA-SAF",
"geolocation_status": 3,
"lat": "37.7999",
"locality": "USA-SFO-MRS",
"long": "-122.4342",
"metro": "USA-SFO",
"region": "USA-SFO-SAF",
"state": "USA-CA",
"zipcode": "USA-94123"
},
"price": 150.0
},
{
"category": "SAUT",
"category_group": "SSSS",
"external_id": "4459983854",
"heading": "Car frame extra light castom made",
"location": {
"accuracy": 8,
"city": "USA-SFO-SNF",
"country": "USA",
"county": "USA-CA-SAF",
"geolocation_status": 3,
"lat": "37.7999",
"locality": "USA-SFO-MRS",
"long": "-122.4342",
"metro": "USA-SFO",
"region": "USA-SFO-SAF",
"state": "USA-CA",
"zipcode": "USA-94123"
},
"price": 300.0
},
"success": true,
"time_fetch": 9.4971656799316406,
"time_search": 42.315006256103516,
"time_taken": 183.84885787963867
}
My users are looking for:
{name:"tom",wants:"new car"}
{name:"john",wants:"Road Bike",price:[low:100,high:1000]}
{name:"becky",wants:"dolls"}
{name:"sam",wants:"Drobo",price:[low:0,high:500]}]
...
...
...

Core data relations between objects

Please suggest about how to create relation in Core Data in the following situation: I created a user object which contained 2 relations pointing to the same object (address) but relation names are homeAddress and workAddress. But on Xcode5 it gives some warning that the inverse relation is not reciprocal.
JSON:
{
"user": {
"user_id": "123123",
"email": "user#email.com",
"first_name": "Jean Luc",
"last_name": "Picard",
"home_address": {
"street": "DowningStreet",
"number": "11",
"city": "London",
"state": "GreaterLondon",
"country": "UnitedKingdom",
"zip": "SW1A2QAB",
"name": "Homesweethome",
"created_at": "1365526421456",
"location": {
"latitude": 3.1,
"longitude": 3.2
}
},
"work_address": {
"street": "AmphitheatreParkway",
"number": "1600",
"city": "MountainView",
"state": "California",
"country": "UnitedStates",
"zip": "94043",
"name": "WorkHarder",
"created_at": "1365526642123",
"location": {
"latitude": 3.1,
"longitude": 3.2
}
}
}
}
I want to avoid creating 2 separate address objects.

Resources