I am hoping someone can help me on this one as i have been trying to find the solution for a long time without success.
I have a polygon shape-file which i am displaying on browser using geoserver . I have color-coded the polygons (by creating an SLD file) based on the values of one of the attributes(say "count") in the shape-file.
My problem is that i want to update the "count" attribute (which is an integer) regularly(on a daily basis) and hence i want to reflect this change in the geoserver. I am getting the values for "count" attribute through a java service which i have up and running . But so far , i have not been able to find out a way through which i can update a single attribute(for all features) in a shape-file through java . The geoTools library helps me to read a shape-file but i could not find a way to modify an attribute using this library .
How do i go about this?Please help me with the following questions:
Is geoserver a correct choice for my use case?
Is there some way to update an attribute of a shape-file using java.?
Should i continue using a shape-file or move to POSTGIS?
Can we update attributes of features in POSTGIS using java.?
If you only need to show one layer, and that layer is not very big (what is the size of the shapefile?) i will convert the file to geojson and show it directly in the browser.
Geoserver is commonly used with shapefiles when the underlying data does not change. If not is common to use postgis
Sure. Geotools can do it. But geoserver can also do it using WFS-T. Just enable it and use POST request or the geotools wrapper to update the data.
I think that the best option is create a new user for you backed process and add a security rule that allows wfs.Transaction only for that user. You can use basic http authentication in your backed process to launch a POST http request that update the shapefile.
It depends. If is one shapefile and it doesn't change a log (once a day) i will probably use in this order:
geojson directly show in the browser (without geoserver) -> shapefile + geoserver -> postgis + geoserver
Of course. A postgis layer is only a postgresql table with a column of type geometry. You can update your table as you can update any other table in postgresql.
I can't provide a full example right now to update a shapefile with geotools but check2 this links.
Open the shapefile as show in the access section in the second link
Open a transaction as show in the first link
Use the setAttribute methods of the feature instances
Close the transaction
A few things:
I would not use a shapefile for doing this but rather a real DBMS like postgis. Shapefile are good for serving read-only datasets not for concurrent changes. Having this in mind if we are talking about a low traffic site with infrequent updates (yes, one a day is infrequent) shapefile should be ok.
You can modify shapefile with GeoTools as well. This link might help. Something similar can be done to update a column in Postgis or you can do it directly.
You can use WFS-T for the update with both Shapefile and Postgis. Notice that by default WFS-T is enabled in GeoServer and it is open to everybody, you might want to change that (i.e. enable authentication at the very least for write operations)
Hope this helps,
Simone.
Related
I am currently developing a program in Java using NetBeans that manages expenses. In this program I used MySQL to store data. Now I want to ask that if I give the program to one of my friend, he would also have to install MySQL using the same password that I used. Is there a way in which he will not be required to install MySQL?
Now suppose if my friend already has MySQL, but with a different password. My program would not work in that case, and it would be hard to replace my password with his password in the code. Is there a way to make the program run on his PC?
Earlier once, I have used an Oxford dictionary program. That time I did not have Microsoft Access installed. When I installed Microsoft Access I came to know that all the words of the dictionary are stored in a Microsoft Access file. How can I do this? I.e. how can I use MySQL/Microsoft Access to store data without the need to install either of them?
You can use an in-memory database like H2 Database if you don't require a large amount of data
But I think you should make your db connection configurable by using a properties file
If you want everyone to be able to use the database, you need to run it on a server that people can access through the internet.
However if you don't care about them using the same database and just want them to use their own, you could for example create a small file named "config.ini" or something like that and put the login information (like the password) in there.
Then just read it in your code and use the info you read to log into your database.
That way, every new user will only have to change the config.ini file without ever having to touch the code.
The best solution in my opinion would be SQLite as it is light, and data can be stored locally in a desired location in a single file. H2 is more likely to be a developer tool.
This solution does not require additional software to be present on the user machine. Of course it has its limits, but as a simply storage for program dynamic data it is a good solution. It is worth mentioning that Android applications also can store their data in LiteSQL. It is a bit different approach there, but the principle stays the same.
We are trying to develop a website for tracking the progress of pipeline and assets. I want to link progress data entered from forms developed in Java to GIS. We will be capturing all the lat and longs of pipeline stretch and lat and log of progress of work.
I need help in developing shapefile dynamically based on the progress and also to view that shape file in my webpage
The javascript API does have functionality for uploading shapefiles form your desktop into the browser, but you will need another tool to create those shapefiles based on the progress.
For uploading the shapefiles, see the example here: https://developers.arcgis.com/javascript/3/jssamples/portal_addshapefile.html
There may be more examples available at https://developers.arcgis.com/javascript/3/.
For creating the shapefiles dynamically, you could use ArcMap or ArcPro if you have those, or one of many python libraries to help write shapefiles. There may even be some Java libraries to help with this as well but I only work on the front end so I cannot help you there.
For something simple in context, the complexity of what kind of workflow to best suite your needs can range depending on these questions (and probably others I'm not thinking of):
Do you absolutely need to create a shapefile for this? Why can't you just push the form to a spatial database (e.g. PostGIS) and then return the XYs of the points or the string of XYs for line features, etc.?
Where is the source of the data & what is the format? Is it a PDF, text on an HTML page, a .csv file downloadable from a page, etc.? You may need to implement scraping (from a site) or download and update, or your data could be live streaming - these are all different workflows and you need to establish these boundaries before setting up your workflow.
If your end game are points, all you need is XYs in a table format to display in GIS software. If they are lines or polygons, it'd be a little different. Again - what output type are they and what are you trying to do with it (e.g. import into QGIS)?
Without these answers, it doesn't make sense for anyone to suggest something to you that could be totally impossible for you to execute. Please answer these and think through your workflow from beginning to end and/or visa versa.
Cheers,
Shawn
I'm asked to develop an automated mail alert in Lotus notes using Java.
The hard part is that the mail content will be tables and each table will be placed inside a tab. I used richtext programming to create tabs first and then iterated each tab, inserted a table and then inserted data into the table.
The problem I face is when I try to format the tables inside the tabs. For example, O need to apply different colors to each column of the table which I couldn't. Let me know if there is any other way to generate the automated email.
I use Eclipse IDE and back end is Oracle 11g. The following link is where I got the idea of how to insert a table and tabbed table: http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=%2Fcom.ibm.designer.domino.main.doc%2FH_APPENDTABLE_METHOD_RTITEM_JAVA.html
The Note Java classes offer pretty limited functionality for formatting tables. If you want more control, the easiest option would bue the Midas Rich Text LSX from Genii Software, however that is commercial software and it is generally used in LotusScript. Off the top if my head, I don't know if it's supported for Java.
Another option is to use DXL. What I would probably do is manually create an email containing a table with the exact look and feel that I want, export that email to DXL, and then write my code to insert my data into the DXL and then import the DXL into the document that I'm mailing.
IMHO the pragmatic way is to use HTML and MIME, and prepare the tables and tabs using hHTML and the NotesMime classes. Here's a link: http://www-01.ibm.com/support/docview.wss?uid=swg21098323
Why not use the Java interface in Notes to pull information into that environment rather than push the information/format into Notes? The Notes designer is Eclipse based. Plus with the recent changes in Notes external db access is simplified.
I am just trying to think a different direction but still using Java. The Notes side might be faster for you.
I am collecting data from a website and trying to save it to a database (or something similar that is very accessible) rather than having a heap of files on my desktop or in a folder.
There are many pages that I need to look at (1900 to be exact). I want to save time in getting this data, and decided to make a Java program to do this.
This is basically what I am trying to do.
Visit the webpage: www.TestWebsite.com/items/0
Save the (Name, Description, Image(png)) into one array/class to a Database.
Repeat until I get up to: www.TestWebsite.com/items/1899
I want to be able to access this data offline without having to need to go online to view it.
Any ideas on how I should start. I have made a basic webpage viewer, I am just missing the step in between saving the strings and images to a database.
I appreciate any help!
Actually just did this the other day. I used jsoup to scrap the webpages I needed and wrote to my local database. awesomely easy framework for webpage parsing.
It's fairly straightforward, but you'll need to learn a little SQL if you haven't already.
You'll also have to pick a database platform - I'd suggest SQLite for such a purpose, since the data is for personal use and it's lightweight and easy to set up.
Here's a tutorial on using JDBC (Java Database Connectivity) to talk with a SQLite database: http://en.wikibooks.org/wiki/Java_JDBC_using_SQLite. It goes from setup to inserting data, so once you've completed that it should be straightforward to modify your webpage viewing code to grab the data you need and shove it into the DB.
Good luck!
My work has tasked me with determining the feasibility of migrating our existing in-house built change management services(web based) to a Sharepoint solution. I've found everything to be easy except I've run into the issue that for each change management issue (several thousand) there may be any number of attachment files associated with them, called through javascript, that need to be downloaded and put into a document library.
(ex. ... onClick="DownloadAttachment(XXXXX,'ProjectID=YYYY');return false">Attachment... ).
To keep me from manually selecting them all I've been looking over posts of people wanting to do similar, and there seem to be many possible solutions, but they often seem more complicated than they need to be.
So I suppose in a nutshell I'm asking what would be the best way to approach this issue that yields some sort of desktop application or script that can interact with web pages and will let me select and organize all the attachments. (Making a purely web based app (php, javascript, rails, etc.) is not an option for me, so throwing that out there now).
Thanks in advance.
Given a document id and project id,
XXXXX and YYYY respectively in
your example, figure out the URL
from which the file contents can be
downloaded. You can observe a few
URL links in the browser and detect
the pattern which your web
application uses.
Use a tool like Selenium to get a
list of XXXXXs and YYYYs of
documents you need to download.
Write a bash script with wget to
download the files locally and put
in the correct folders.
This is a "one off" migration, right?
Get access to your in-house application's database, and create an SQL query which pulls out rows showing the attachment names (XXXXX?) and the issue/project (YYYY?), ex:
|file_id|issue_id|file_name |
| 5| 123|Feasibility Test.xls|
Analyze the DownloadAttachment method and figure out how it generates the URL that it calls for each download.
Start a script (personally I'd go for Python) that will do the migration work.
Program the script to connect and run the SQL query, or can read a CSV file you create manually from step #1.
Program the script to use the details to determine the target-filename and the URL to download from.
Program the script to download the file from the given URL, and place it on the hard drive with the proper name. (In Python, you might use urllib.)
Hopefully that will get you as far as a bunch of files categorized by "issue" like:
issue123/Feasibility Test.xls
issue123/Billing Invoice.doc
issue456/Feasibility Test.xls
Thank you everyone. I was able to get what I needed using htmlunit and java to traverse a report I made of all change items with attachments, go to each one, copy the source code, traverse that to find instances of the download method, and copy the unique IDs of each attachment and build an .xls of all items and their attachments.