I want to find routes using OSRM (Open Source Routing Machine) avoiding a certain area of the city, specified by a polygon, as an option. One approach is to make two profiles: car and car_avoid_no_drive_zone. The latter profile looks up each way segment and sets the length to infinity if it is inside the no drive zone.
But this approach technically duplicates the pre-processing, disk usage and RAM usage. Is there any better solution to this problem?
it is possible to block some area via a "traffic update" by setting 0 speed on all OSM segments on the border of the restricted area and doing only CH contraction or MLD customization. This approach will still generate two graphs. More information here https://github.com/Project-OSRM/osrm-backend/wiki/Traffic
Another way is to use a coming soon "avoid" feature https://github.com/Project-OSRM/osrm-backend/pull/4315 by defining a "restricted area" class in a profile and using a query parameter like avoid=restricted at runtime.
Related
Here is the Story of current implementation:
I have over 50 Ad Campaigns. To track the user-behavior, I have implemented Floodlight Count tag for all of those. However, it is eating up lot of container size. Therefore, I am looking for a solution with which, I can dynamically fire Floodlights or without implementing Floodlights, I can get the similar result.
I already have implemented this solution. However, it increases the Loadtime of the webpage as it contains RegEx table(and my RegEx table has over 50 entries).
I am looking for a solution which involves minimal use of Custom variables by mostly using what is available by-default in GTM.
What's available by default in GTM (not counting custom variables) wouldn't be sufficient for covering 50 ad campaigns in an effective manner. You could always create 50 triggers and 50 tags, hardcoding your ids and maintain them separately in different tags, which is quite far from being the best practice. It actually may be the worst practice, especially given how the container size is hard-limited for GTM.
Even a large rLUT should be very insignificant given that the variable against which it's executed is reasonably small and the url is most definitely a tiny string. Have you actually measured the page load speed with and without the rLUT? Have you debugged the load speed issues and narrowed them down to the rLUT? It's actually quite an achievement to make GTM significantly affect the page load speed, given how it's all async and non-blocking.
You could reimplement the rLUT in a CSJ variable, which may be more preferable if you're good at JS, but it won't improve performance. Just like an rLUT won't hinder performance.
I have a react-native application that populates pins on a map that have been submitted by users. The front end gets the corners of the window and then the back end goes through each pin to check if it falls within the boundary, and returns the ones that do.
This is taking too long on the backend and I want to ask the community for ideas, because I doubt I have the best one.
My idea is to store tables of pins grouped by quadrants, effectively a cache, and then I can in almost constant time return the pins from the quadrants involved.
Is there a simpler way to do this?
Maybe using NoSQL?
🙏🏻
A month later it seems geohashing is probably the best way, plus AWS has a library for automatically handling this with dynamodb. Apparently it takes the corners of the screen, lat/lon, and automatically returns the items from the DB in the view, in, I assume, constant time, since that's the whole point of geohashing, getting performance that works at scale..
https://www.npmjs.com/package/dynamodb-geo
https://aws.amazon.com/blogs/compute/implementing-geohashing-at-scale-in-serverless-web-applications/
Otherwise, using a geohashing library that is built for serving mobile apps likely exists.
Good afternon! How can i get a route summary for each country in the route? For example, I want to move from Ukraine to France. I get route from GetRouteDirections, the route runs through 4 countries, and i want to see - how many kilometers this route takes over each of the countries of the route
Currently the Azure Maps routing service does not provide an option to return this information, although it is something being considered as a future feature. I have seen this question in the past with other mapping platforms, and there was nothing out of the box for this in those platforms either.
That said, if you want to achieve this today you can do the following:
Get a set of country boundaries that are suitable for your users (if you have users in countries that have disputed borders, you will likely need several sets of country boundaries).
Calculate a route and use path to create a line.
Calculate the intersection of the line with each country boundary and then measure the length of the section of line that intersects.
I've done this as a proof of concept in the past using a set of GeoJSON country boundaries and the JavaScript topology suite (https://github.com/bjornharrtell/jsts). I haven't posted the code online as country borders are disputed in some regions and thus, any sample I put out there wouldn't work globally.
A global solution could be achieved by retrieving the country boundaries from Azure Maps, but you would need to retrieve the boundaries for all countries first, which would be a bit time consuming and generate a lot of transactions.
I want to build a database of geographical locations and would like to be able to identify locations that fall inside other locations. For example, The Empire State Building is going to have one geo-coordinate, but my database would be able to tell me that it falls inside Manhattan, which falls inside New York City, which is in the state of New York and so forth.
I've been looking at OpenStreetMap which seems to have a pretty decent database but as best I can tell, I would need to create a set of polygon structures representing each region and then detect if a coordinate falls inside a given region's polygon. Is there a better way to do this, or is there a data source where all of this has already been calculated?
Try the Yahoo! GeoPlanet Data at http://developer.yahoo.com/geo/geoplanet/data/
It is already organised into a hierarchy structure, countries, admin divisions and places.
You can also extend the data by using the 'Geo' methods of the YQL API at http://developer.yahoo.com/yql/console/
You also may want to look into the Geonames database. While it is not classified using hierarchical method, you could probably derive the information out of it.
If you really want to dive into building a geographical database where you can analyze the data, take a look at loading your data into the free/open-source PostgreSQL/PostGIS stack. With that you can actually write SQL that answers questions like "show me all points [within a city/county/state boundary]" or "[within X distance from Y location]".
Good places to learn more about PostGIS is at the BostonGIS website, the GIS.StackExchange pages, or of course the manual but who reads those anymore...
I'm pretty sure the google maps API has regions defined as polygons. And by regions I means, State, City, Zip Code, or just about anything that could be defined as a "region"
You would have to hit-test (Google Maps might have a function for this already) a point to see if it is inside a polygon.
You could also use the lookup address by GeoLocation functions to find which region(s) a point resides in, and just use that.
Can anyone please give me any example of situation in a database-driven application where I should use Flyweight pattern?
How can I know that, I should use flyweight pattern at a point in my application?
I have learned flyweight pattern. But not able to understand an appropriate place in my database-driven business applications to use it.
Except for a very specialized database application, the Flyweight might be used by your application, but probably not for any class that represents an entity which is persisted in your database. Flyweight is used when there otherwise might be a need for so many instantiations of a class that if you instantiated one every discrete time you needed it performance would suffer. So instead, you instantiate a much smaller number of them and reuse them for each required instance by just changing data values for each use. This would be useful in a situation where, for example, you might have to instantiate thousands of such classes each second, which is generally not the case for entities persisted in a database.
You should apply any pattern when it naturally suggests itself as a solution to a concrete problem - not go looking for places in your application where you can apply a given pattern.
Flyweight's purpose is to address memory issues, so it only makes sense to apply it after you have profiled an application and determined that you have a ton of identical instances.
Colors and Brushes from the Base Class Library come to mind as examples.
Since a very important part of Flyweight is that the shared implementation is immutable, good candidates in a data-driven application would be what Domain-Driven Design refers to as Value Objects - but it only becomes relevant if you have a lot of identical values.
[Not a DB guy so this is my best guess]
The real bonus to the flyweight pattern is that you can reuse data if you need to; Another example is word processing where ideally you would have an object per "character" in your document, but that wuld eat up way too much memory so the flyweight memory lets you only store one of each unique value that you need.
A second (and perhaps simplest) way to look at it is like object pooling, only you're pooling on a "per-field" level as opposed to a "per-object" level.
In fact, now that i think about it, it's not unlike using a (comparatively small) chunk of memory in c(++) so store some raw data which you do pointer manipulation to get stuff out of.
[See this wikpedia article].