Good day i am rather new to osm navigation. I like the graphhopper library however i wish to modify the route as the user traverses with a winking indicator in real time. How can be approach.
Related
I'm developing an Angular2 workflow app that collects data on multiple tabs, customizing the fields on each tab based on prior tabs' values, and then validating that all tabs are filled out correctly along the way. I'm using the Angular2 router to control which tab component displays, and each tab uses FormGroup to handle form validation. (See below for a visual idea of component hierarchy and how the app works.) I need an elegant way to compute the validity of data across all tabs in the workflow, without having to open each tab to activate its controller and FormGroup validators. Ideally, the workflow validation for a tab will use the same logic as the tab's FormGroup validation, to keep things DRY and consistent.
As users touch fields I log the tab's "dirty" state in the DB, so I don't have a problem knowing when a tab is pristine/dirty. The challenge is, when a user returns to a previously-saved workflow, how do I compute the valid/invalid state for all tabs' data, when the user hasn't yet touched the FormGroups on those tabs?
Thanks for any suggestions for design patterns that can accomplish this!
A few design details:
One route component handles each step of the workflow.
Each route component uses a FormGroup to handle form validation.
Form validation on all tabs need to drive the valid/invalid indicators for all workflow steps, shown in the header's .
A tab can be in one of three possible states: Pristine (gray check: the user hasn't touched any field on the tab yet), Incomplete (red exclamation: the tab has been touched and one or more fields on the tab are invalid), Valid (green check: all required fields contain valid values.
In working on this problem, I am finding that the solution requires higher-level architectural choices about state management and how to handle & display the app's data. Unfortunately for me, there wasn't a single technical solution, like "Use this Angular2 library design specifically to validate fields across multiple FormGroups in different components!" :(
I hope our research is helpful for somebody else, my team is taking a Redux approach using the npm modules ngrx-store & ngrx-effects for Angular2. All of the app's data & state processing logic (including validation across multiple tabs-- my initial challenge) will be handled by Redux actions & reducers. A beneficial side effect is that our view controllers become super simple, and just display the data ngrx gives them. This eliminates complex, conditional logic that depends on state of data entered in other areas of the app.
Egghead.io has a useful 10 minute video that introduces the ngrx library & design patterns.
I hope this gives you a leg up. Good luck!
Four years later, I have a better answer to the initial question:
There's a module for that! https://www.npmjs.com/package/#ngneat/forms-manager
For state management in general, I now use Akita, https://datorama.github.io/akita/. I hope I never have to use redux again. I imagine there are legitimate use cases that need redux, but having now used ngrx in a few projects, I can say with confidence: It is very complex to implement and maintain, and painful for each new team member that has to come up to speed.
Both tools are created by (or at least heavily contributed by) Netanel Basal (https://netbasal.com/), so it's also nice that they share the same mindset about state management.
I would like to display a couple of function graphs in a web browser. That is, I have a few functions, like distribution or density functions, regularly generated by data analysis tools and I'd like to make those accessible via a web browser. They should be rendered as line charts, actual values displayed e.g. in a tooltip when hovering over the chart. The ability to zoom in would be nice but not essential. Also, a nice dashboard like arrangement would be nice. Now I have the data (each function represented as a list of floats), how do I best render them?
Generating static images might be an option, but they're not interactive at all. I see there are javascript frameworks to display charts, but I have the feeling there must be some ready-made solution out there to grab numbers from a file, or DB, or wherever, and show functions; hence, I don't want to start writing my own javascript. I thought about Grafana, but that's time series oriented and my data is not time series. I thought about importing the data into Google spreadsheets and create charts there programmatically, but I'd like to have at least a few thousands data points per chart and am not sure if that would work out performancewise.
What do you suggest?
use the simplest php Graph library. PHPMYGRAPH.
http://phpmygraph.abisvmm.nl/
I have an edit page which is grows with the size of the app. We're now running in to a situation where the server side action (MVC) is handling image uploads and conversions alongside regular text saving to database.
What's the best way to make this more maintainable? Separate controller for images uploads, so that we create an writeable API? Or more actions within the same controller?
There are few ways, which could let you mitigate the problem with rising complexity :
Implement HMVC, where each controller calls sub-controllers. This would let you to split up the "update" tasks in logical and manageable chunks. Especially, if i am correct in thinking that there is more the one "update page". The HMVC structure would let you to assemble different update pages from existing fragments with quite minor additional hustle. Main disadvantage: relatively large change in architecture.
Split the update page(s) in smaller forms, each submitting to a different controllers action (or maybe a different controller altogether). Main disadvantage: user can update only one part at the time
Evolve the model layer, so that the API you use interacts with service layer instead of domain model layer. This will let you isolate the complexity of updated and provide a simpler interface to use in controller. This too would have the added benefit of composing update form(s) from manageable pieces. But i don't know the penalties that come with this approach .. never have used it myself.
The bottom line is: you will have to change one part of MVC. In your situation i would choose the HMVC way, but mostly because i am familiar with it, and multiform page might induce rage from users.
My app uploads an image and stores the image info in the database. If needed it manipulates the image. There are several points in the site where images can be managed like this.
In each case I have an action imageuploadAction() that handles things. Because I have slightly different requirements depending on the part of the site the image is going to be used in there are several different imageuploadActions in various controllers of the site. I want to combine them all into one, however, to make the app easier to manage.
So, my question is what is the best way to handle a site wide image upload capability within Zend Framework? I feel it must either be:
Have one action that does it all and the various controllers would use that action, or...
Create some sort of plugin that does it. An Action Helper Plugin perhaps? Maybe a controller plugin of some sort? What sort of plugin is the best way to do this?
I'm inclined to think 2 is the way to go but want your feedback on this. Thanks!
Oh, and the plugin (or action) will handle physically uploading the photos, categorizing them, flagging them for various uses, resizing as needed, passing data to the DB for all CRUD actions as necessary, etc. etc.
What you are describing is what action helpers were designed for, so I'd suggest creating an action helper for handling uploads and moving as much of your processing code into that as possible. However you still need to call that helper from your controllers, so then it really comes down to what suits your application - a central controller that handles the uploads (by calling your helper) or calling the helper from the relevant points in your existing controller methods.
If you can get to a point where your image upload actions are as simple as this:
public function imageuploadAction()
{
if ($this->_helper->HandleImageUpload([...])) {
[...]
}
}
then I'd say you're in pretty good shape, and you can always reuse the helper elsewhere if any parts of your app need to handle an image upload and some other data in the form at the same time.
I am writing a Catalyst web application that presents some data that does not change in between requests. I want to load this data when the application starts and stick them somewhere so that the relevant controllers can use them. Where should I load this data and where should I store it? At first I tried to load it in the main App.pm file and put them into the application config. This works, but it’s ugly, since the App.pm file gets littered by a lot of loading subs that don’t really belong together:
__PACKAGE__->config(this => load_this());
__PACKAGE__->config(that => load_that());
# et cetera
Then I figured I could load some of the data in the controller that uses them and store them in the controller’s config hash. This is not perfect either, because some of the data is needed in more than one controller.
I also thought I could localize the data to the controller instead of sharing them. This feels nice, because I would have all the code that works with the data more or less on one place. The problem is that the controller would also have to render parts of the resulting page for other controllers – for example if the title page controller wanted to display a list of recent news, it would have to ask the news controller to render the list. This does not seem to be the preferred way of doing things in Catalyst.
How would you solve this?
(The nature of the data: This is a website of a music festival. There is a line-up, a list of sponsors and other simple data pulled from YAML files, because database would be overkill and hard to edit.)
Fundamentally, the data should belong to the Model, which is to say your YAML files should be represented by modules in your application's Model. That's one reason you separate the model from the controllers in the first place: All of your controllers can talk to the same models, without having to replicate their information within themselves.
There's no reason you can't cache the data persistently in these modules, using plain perl data structures or whatever caching technique you like.