How to load a shapefile in gwt-openlayers - shapefile

We're building an application using GWT-Openlayers (not OpenLayers) and need to allow the user to load a polygon from a shapefile. Surprisingly, there doesn't seem to be an evident solution. The closest solutions are javascript libraries for interpreting shapefiles, but a javascript solution doesn't really help in a GWT application. Any recommendations?
Thanks in advance!

Lacking a simpler solution, the approach I used was as follows:
Use GWT FormPanel and FileUpload to allow user to select the file to upload
Create a custom servlet for handling the request
FormPanel sends a multipart POST of the file contents to the servlet
Servlet feeds the file content to a parser to convert to Well Known Text (WKT)
Servlet returns the WKT in the HttpResponse
Client side code converts the WKT to a gwt-openlayers vector feature and adds it to the map
Certainly not an elegant solution but seems to work. If anyone finds a better solution, it would be great to hear.

Related

How to download content from my Django webpage?

I have a table on one of my Django webpage. I want to give the user the ability to download the content of the table in xl format.
What would be an efficient and good way of doing this?
I was thinking of creating an xlsx file using the xldr library. Writing the data on the file. making the file available for download and then deleting the file at the end, so that my drive stays clean.
but it doesn't feel like a very efficient way.
I'm new in web development, so open to all kind of ideas.
Thanks
There's an example in the python doc of generating a pdf response. Apart from using xldr I don't suppose it needs to be much different, though I haven't done this. It uses io.BytesIO in-memory buffering to avoid creating temporary files, and sends that back using FileResponse instead of HttpResponse

Converting HTML file to PDF using Win32/MFC

As part of my application, my client has requested that I include an automated e-mailing system. As part of this system, I generate HTML code and use automation to send it via. Outlook.
However, they also require a PDF copy of the HTML document to be sent as an attachment. My initial attempts involved using libHaru, which proved difficult to use efficiently, as I was required to create the PDF document from scratch, which required computation of the position of each of the lines in a table, and positioning of all the text, etc.
I was wondering if there would be a way to programmatically convert HTML code (or an HTML file if need be) into a PDF document either by using Win32/MFC itself or an external library.
Thanks in advance!
EDIT: Just to clarify, I am looking for solutions which minimize external dependencies.
You should evaluate this utility wkhtmltopdf:
http://code.google.com/p/wkhtmltopdf/
You can call it from the command line without the need to run a setup.
I use it generating my output documents as html then cal a ShellExecute(...) to convert it to PDF. It's great!
Inside uses webkit + qt. So compability with modern HTML is OK.
Hope it helps.
I'd take a look at PDF Creator, which can be used as a COM object (that acts pretty much like a printer). I haven't used it to print HTML, so I'm not sure, but my guess is that you'll probably end up having to instantiate a web browser control to render the HTML, and then feed it from there to the PDF control.
Some possible answers are in this thread:
C++ Library to Convert HTML to PDF?
Not sure if they will satisfy your particular requirements, but these might at least get you started.
Edit:
Some other possible options here.
Not MFC but you can try QtWebKit. It can render and export HTML to PDF, PNG, JPEG

Django big file transfers

I am looking for a django app that can help smooth the process of uploading big size documents by using HTTP Post.
Documents ranging anything from 150mb to 500mb.
I wrote a small library that handles PDF uploads and parses it to my scribd library and through that embed it onto my site.
Currently my model is quite simple, it takes a FileField, preferably PDF and just and uploads the PDF File, through that makes use of the scribd library and send it directly to scribd for encoding.
The problem is, somewhere along the actual upload process, it times out, no errors in the log, I have adjusted my django apps size for files, Apache's size for files, and I am a bit lost at the moment not knowing where to go from here.
Although I want to eliminate the manual work, so ideally I'd still like to use it through my site.
Any help or pointers would be appreciated.
Probably a bit too late, but, have you tried django-bft

Get a particular text from website

I'm looking for a way if you know the location where to read the text for example say, under a particular category, how would you connect to a website and search & read the text from it?
what steps do i need to follow to learn about that?
you could use libcurl/cURL for your HTML retrival
You're probably looking for a web crawler.
Here's an example of a simple crawler written in C++.
Moreover, you might want to have a look to wget, a software to retrieve files via HTTP, HTTPS and FTP.
if you are looking at a specific web-page, you could try retrieving the page and parsing it to get to the exact location you want. e.g. specific div, etc.
since you are using c++, you could try reading up on using libcurl to retrieve the information you need from the URL.
You can download an html file with WinHTTP(working example) and then search the file. There's some find algos in the std::string class for searching if your needs are relatively basic.

building objects from xml file at runtime and initializing, in one pass?

I have to parse the XML file and build objects representation based on that, now once I get all these data I create entries in various database for these data objects. I have to do second pass over that for value as in the first pass all I could do is build the assets in various databases. and in second pass I get the values for all the data and put it in the database.
I have a feeling that this can be done in a single pass but I just want to see what are your opinions. As I am just a student who started with professional work, experienced ppl please help.
Can someone who have ideas or done similar work, please provide some light on the topic so that I can think over the possibility of the work and get the prototype going based on your suggestion.
Thanks a lot for your precious time, I honestly appreciate it.
You might be interested in learning several techniques of building XML parsers like DOM or SAX. As it is said in SAX description the only thing which requires second pass could be the XML validation but not the creating the tree.
Beside DOM and SAX parsing, you can use XQuery for querying data from XML files.It is fast, robust and efficient.
here is a link
You can use Qt Xml module for DOM ,SAX and XQuery, btw it is open source.
Another option is xml - C++ data binding, Here is the link.You can create C++ codes from definition directly.It is an elegant solution.
EDIT:
the latter one is at compile time.
You can also use Apache Licensed http://xmlbeansxx.touk.pl/. It works under Windows and Linux.
you could take a look at the somewhat simpler 'pull' api called stax instead of using sax (event based).