I have a question in WP8 app development.
So that's what I wanna do:
I have multiple busses routes like:
Bus 1: start's from street ... end's with street ...
Bus 2.........
I add 2 text boxes where user enter:
1. From(street name) and 2. Destination(street name)
and I need to perform a search in every bus route and show the results with wich bus user can get to destination.
the only thing I need to understand is where to save the bus route and how to perfom a search in that file or string? here's a little code:
int search(string *from, string *to)
{
char[200]; int busnumber;
//first compare if the from matches
for(busnumber=1; bussnumber<10; bussnumber++)
{
if(stricmp(from,busnr[busnumber])==0)
{
if(stricmp(to,busnr[busnumber])==0)
{
return busnumber;
}
}
}
}
I didn't understand your question well but here's what I can think of.
If you have data ordered in following manner:
[bus_number][start][destination]
and your data omit all the middle bus stops, then you have to simply iterate through the list.
Although if there is an option that user wants to find path to a place for which there is no direct bus, and he will have to change buses, then you have to use graph and an algorith that efficiently searches the path.
You will also have to use weighted graph if your data is as following:
[bus_number][start][busstop2][busstop3]...[busstop(n-1)][end]
and find a path with a constraint for example that you cannot have more than three buses changes.This algorithm will be a little bit complicated.
Related
maybe someone can help me with a overpass-turbo.eu-query.
I'd like to highlight (center of it) all cities of a country or region (or current map).
Is there maybe an "simple" example on web?
(Google was not a good friend with this special request, yet. But I am sure someone must tried to search this way already.)
Many thanks for every idea.
Here is an example for finding all cities, towns, villages and hamlets in the country Andorra:
[out:json][timeout:25];
// fetch area “Andorra” to search in
{{geocodeArea:Andorra}}->.searchArea;
// gather results
(
node[place~"city|town|village|hamlet"](area.searchArea);
);
// print results
out body;
>;
out skel qt;
You can view the result at overpass-turbo.eu after clicking the run button.
Note: When running this query for larger countries you might need to increase the timeout value. Also rendering the result in the browser might not be possible due to performance reasons. In this case use the export button and download the raw data instead.
I have a topojson map that has both county and state data in json format. There are no actual names for the states, but the states do each have a unique id. I would like to find a way to return the id of a state if the user clicks on one of its containing counties.
The trouble is I cannot seem to be able to access the state ids in the json when I set up my click event listener. I have sliced and diced the json data every which way, but I keep going in circles. Is it possible to have asymmetric information within the json file? I feel like the state ids are in a black box when working with the containing counties.
Let me know if anything comes to mind. I have a fully functional minimalist example here, where I am trying to return a console log of the state id based on user click.
Note: I would prefer to avoid point in polygon solutions for complexity reasons.
Seems your json file ships with FIPS county code. That means that first two digits of county code are in fact the state code. So Math.floor(county.id / 1000) is what you‘re looking for in the end.
I have an existing live neo4j db with relationships like this...
User-[:Owner]->Item
User contains the usual properties; name, email etc.
Owner relationship has created_on property
Item has a bunch of properties about the item; title, description etc.
I want to add in a geo-location property for the Item. This will be a latitude and longitude of where the user created the item.
A JSON api is serving up this data to our clients. The API will merge some of the data, so an Item object in the api will have a nested User object as a property of it...
"item": {
"title":"my item",
"user":{
"name":"smith"
}
}
And I was initially thinking the location would follow suit...
"item": {
"title":"my item",
"user":{
"name":"smith"
},
"geo_position":{
"latitude":"10.123456789",
"longitude":"10.123456789"
}
}
As we cant nest data in Neo, was wondering how to store this data...
JSON serialise the latitude and longitude data under a geo_position property of the Item ?
As properties of the relationship Owner.latitude?
As a new Node ? Location `User-[:owns]->Mite<-[:created_at]-Location?
As individual properties of the Item so not nested, item.latitude ?
1 - I assume we cant query.
2 - doesn't feel like the right place.
3 - its extremely unlikely 2 Items will have the same location as lat long is very precise, so almost No Items will share this node, so is it really a node?
So is 4 really the way to do it, and just not nest them ?
m
You own analysis is basically correct. I would go with number 4.
Here is more about why number 2 is not a good idea. Logically: the location of an item belongs in that item's node, not in a particular relationship to it. Practically: if the object changed ownership you should not have to copy its location to a new relationship, and querying for an item's location should be as quick and simple as just getting its node.
I have am new to AS3 and coding in general so this is why I am asking this question. I am trying to make a like semi-proceduraly generated dungeon crawler sort of thing like binding of isaac using flashbuilder and flashpunk.
but this has left me with a problem; I have figured out two ways to do the rooms. Either I can spawn all the rooms at once and have the players move between them using a door entity to block progress or I can load a new world that contains the room inside it and nothing else using FP.world = new world. But this gives me two problems so basically this is the main thing I want to know.
I want the world to remember what was in it and what was killed even if I enter a new world. E.g. right now if I enter a new world it will load that world up fresh and then if I kill all the enemies and leave and then re enter it will just spawn all the enemies again. I need to know how to get that room to remember it has been cleared of enemies.
Is there anyway to do this?
I'm not familiar with FP, so I cannot tell if FP allows to save room states. You better check the documentation, but if it doesn't help, you can do the following:
Find a way to get the room unique ID somehow. It could be anything - a coordinate, a number, a name, an object, etc. Just be sure it is unique. Once you have it, proceed.
The next mandatory thing you need is a way to get and set the room state. I.e. after getting state you can know that there are three goblins in a room. And setting state would be like "remove all and put these three goblins in this room". These requirements are natural as you are going to read and write the room's content anyway. Once you have it, the rest is easy.
Choose how you will keep the state. Let's say, an Object like {goblins:3, chest:1}. If you kill one goblin, it will become { goblins:2, chest:1 }. If you want to remember just the rooms that are FULLY cleared, then you simply need a boolean variable (true/false) as a state object.
You can store the state Object in a Dictionary as a key-value pair where key is the room's unique ID.
var visited_rooms:Dictionary = new Dictionary();
var roomID = ... // unique room id
var savedState:Object = { goblins:3, chest:1 } // read room state somehow
visited_rooms[roomID] = savedState;
Now, upon leaving the room, you get the state info and put it in the Dictionary.
Once you enter this room again, just check if its unique ID is present in the Dictionary and restore the state if so:
var roomID = ... // unique room id
if (roomID in visited_rooms) {
var savedState:Object = visited_rooms[roomID];
room.setState(savedState);
}
That's basically all.
Just started coding with Appwarps and I'm running into an issue. I have a lobby built that shows live rooms, but I really do not want to show the rooms for matches that have already started. I figured I would use
void Client::setCustomRoomData(std::string roomId, std::string customData)
But I have some doubts on how to use it. Once the game starts, I plan on sending
SetCustomRoomData(roomId, "Closed");
to notify the server that open seating is now closed. However, when I check the room properties on another device when it calls
void CCAppwarpDelegate::onGetLiveRoomInfoDone(AppWarp::liveroom revent)
{
CCLog("CustomData=%s",revent.customData.c_str());
...
it returns blank. What am I missing here? Besides the code not working, what really makes me question myself is that I don't understand the mechanics of the properties. How do you have multiple custom properties since you aren't assigning it any kind of index...or do room only have a single custom property at any given time?
You don't need to use customData and instead use only room properties. Room properties is a set of key/value pairs that you can associate with a room.
I recommend you read the following link
http://appwarp.shephertz.com/game-development-center/matchmaking-basic-concept/
So the flow is as follows -
you first create the room using the createRoom API and pass a
properties dictionary containing <"closed", "false">.
Then once the game is active, you use updateRoomProperties API
on the room and pass <"closed", "true"> to the API.
Then when you want to show the list you should use
getRoomWithProperties and pass <"closed", "false">. This will get
you a list of rooms that are not yet "closed".