Create shapefile on Appengine preferably on Java - java

Hi i would like to create a shapefile(.shp .shx .prj .dbf) based on a KML file on appengine. My project is on java.
I tried to use geotools, and was able to create .shp .shx .prj on Appengine (with some changes on geotools to save on Google Cloud) but was not able to create a .dbf with it. Geotools depends on AWT for creating the dbf, and Appengine restricts AWT.
Any sugestion on this? I´m starting even to consider calling a python module or something(never did anything like this). Or even creating just a dbf from a kml.
Thanks
Edit 1:
When i call ShapefileDatastore.createSchema() i have to pass a SimpleFeatureType as argument.
When i try to create a SimpleFeatureType or even use a BasicFeatureTypes.POLYGON it gave me error:
Caused by:
java.lang.NoClassDefFoundError: java.awt.RenderingHints is a restricted class.
Please see the Google App Engine developer's guide for more details.
at java.awt.RenderingHints.<clinit>(RenderingHints.java)
at org.geotools.factory.FactoryFinder.<clinit>(FactoryFinder.java:35)
at org.geotools.data.store.ContentDataStore.<init>(ContentDataStore.java:173)
at org.geotools.data.shapefile.ShapefileDataStore.<init>
(ShapefileDataStore.java:124)
at org.geotools.data.shapefile.ShapefileDataStoreAppengine.<init>
(ShapefileDataStoreAppengine.java:74)
at brandeira.morholt.web.shared.util.ShapefileHelper.createShapefile(ShapefileHelpe
r.java:121)
I twisted a bit replacing RenderingHints by a non awt RenderingHints and them got another error:
Caused by:
java.lang.NoClassDefFoundError: javax.imageio.spi.ServiceRegistry is a
restricted class. Please see the Google App Engine developer's guide for more details.
at javax.imageio.spi.ServiceRegistry.<clinit>(ServiceRegistry.java)
at
org.geotools.factory.CommonFactoryFinder.getServiceRegistry(CommonFactoryFinder.java:76)
at org.geotools.factory.CommonFactoryFinder.lookup(CommonFactoryFinder.java:346)
at org.geotools.factory.CommonFactoryFinder.getFilterFactory(CommonFactoryFinder.java:300)
at org.geotools.feature.AttributeTypeBuilder.<init>(AttributeTypeBuilder.java:192)
at org.geotools.feature.simple.SimpleFeatureTypeBuilder.<init>(SimpleFeatureTypeBuilder.java:196)
at org.geotools.feature.simple.SimpleFeatureTypeBuilder.<init>(SimpleFeatureTypeBuilder.java:186)
at org.geotools.feature.type.BasicFeatureTypes.<clinit>(BasicFeatureTypes.java:101)
at brandeira.morholt.web.shared.util.ShapefileHelper.createShapefile2(ShapefileHelper.java:290)
It seems to use a lot of this factory methods of AWT (graphics is not the problem here in this case, just the use of AWT things).
I replaced that also and got:
Caused by:
java.lang.NoSuchMethodError:
org.geotools.factory.FactoryRegistry.getServiceProvider(Ljava/lang/Class;Lcom/google/apphosting/runtime/security/shared/stub/javax/imageio/spi/ServiceRegistry$Filter;Lorg/geotools/factory/Hints;Lorg/geotools/factory/Hints$Key;)Ljava/lang/Object;
at org.geotools.factory.CommonFactoryFinder.lookup(CommonFactoryFinder.java:346)
at org.geotools.factory.CommonFactoryFinder.getFilterFactory(CommonFactoryFinder.java:300)
at org.geotools.feature.AttributeTypeBuilder.<init>(AttributeTypeBuilder.java:192)
at org.geotools.feature.simple.SimpleFeatureTypeBuilder.<init>(SimpleFeatureTypeBuilder.java:196)
at org.geotools.feature.simple.SimpleFeatureTypeBuilder.<init>(SimpleFeatureTypeBuilder.java:186)
at org.geotools.feature.type.BasicFeatureTypes.<clinit>(BasicFeatureTypes.java:101)
at brandeira.morholt.web.shared.util.ShapefileHelper.createShapefile2(ShapefileHelper.java:290)
I could not yet find where this javax.imageio.spi.ServiceRegistry (i have replaced all i found) is coming from and am thinking that i twisted this a lot and it doesn´t seem to be the way..

Related

Failed resolution of: Ljavax/imageio/stream/FileImageInputStream when using Java library

I'm trying to make an app which creates a DICOM file. There is a java library called PixelMed. I tried to use it in my Android project but when accessing methods from the library I get
Failed resolution of: Ljavax/imageio/stream/FileImageInputStream
From what I found I get this because javax is not a part of Android SDK. My question is: Is there a way to somehow import this library or make the PixelMed work on Android?
Thanks in advance.

How to combine a standalone application with an Android application?

How do I combine a standalone Java application with an Android application?
I have a piece of code taken from the Google quick start examples that perform a task that I can't seem to be able to combine with my activity source code.
I'm of course talking about the following Google example: Sheet API, if I just add it as a standalone class and tell Android Studio to run this application, before my Android application, then it will produce what the code is suppose to do.
If I try to copy and paste the exact code into one of my activities it will give a couple of problems. One is that it can not find my keystore, another is a threading issue which I understand, another being that it can not find the credentials (even if the file is present), the newTrustedTransport-method call will be an issue, the setDataStoreFactory-method call will be an issue, file creation even with the correct uses-permissions and so on.
What is going on in the background that would make exactly the same source code work in one instance and not the other? What do I not know about Android Studio, and how an Android project works in the background for me having these issues?
I had an idea that I could just keep this standalone application as it is and store a file with the result that this Sheet example would provide me. But, since I do not have enough experience with Android Studio I have no idea if the result will be available for the actual Android application once it was made into a release. Will it? I can't save the output file generated by the Sheet example, under the res-folder, under the app module for some reason (scope?).
With other words... Can I have a standalone application, that is tasked to run before the Android application, to gather data and it will be doing this EACH time the Android application is run on a client? I feel like it would be stupid if the IDE would present this like this would actually work but then when the application is made into a release then the standalone application will not "follow" and be part of the release...
If I could just combine the source codes, I will not be having this issue at all. No examples online, neither Github or Youtube can provide me with answers on how to do this. Many examples online provide me with source code that is either out of date or just not what I'm looking for, and I really hate Google's way of explaining things. Just look at how they give code examples under this page: Google API Client Library for Java, and not give a full example where they would fit into the a project. Maybe all I need to make everything work is to use the code under "The library runs on Android 4.0 or higher (#Beta)."

haarcascade_frontalface_alt.xml not working

I am currently working on a java project on face detection. I am using OpenCV API opencv_310 available at the official site and started writing the program following
this tutorial
But the main problem is that this tutorial was written more than five years ago. So the OpenCV APIs and working procedures have changed over the years. So I encountered a problem regarding the file haarcascade_frontalface_alt.xml.
new CvHaarClassifierCascade(cvLoad(FACE_CASCADE_PATH));
This line of code throws the following exception:
OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) in cvRead, file ........\opencv\modules\core\src\persistence.cpp, line 4991
Exception in thread "main" java.lang.RuntimeException: ........\opencv\modules\core\src\persistence.cpp:4991: error: (-2) The node does not represent a user object (unknown type?) in function cvRead
So I browsed the Internet for a while and found this. It says the old C API does not support the newer haarcascade format. It also suggests to try with the C++ API.
What should I do now? I don't know how to try the C++ API. It will be highly appreciable if you can give some instructions on how to deal with the problem.
Thanks.
Try checking this tutorial which is from opencv site. This has a link to the source code. The xml file which you have trouble is the trained data.. if you would like to just download this file, you can find it here
regards

cfdump util disappears when I use linkedin-j with javaloader

I am creating an application using the linkedin-j Java library and JavaLoader, and I am finding that whenever I drop it into a server running ColdFusion 9.0.1, I start getting the following error:
coldfusion.util.DumpHelper
(java.lang.ClassNotFoundException)
I am not doing anything crazy with the library. I have narrowed it down to being caused by the following code:
var l_user = api_client.getProfileForCurrentUser();
api_client is an instance of the client object in linkedin-j. I don't know a whole lot of Java, but I don't see anything in there that should break ColdFusion's utils.
Upon testing, this doesn't appear to happen when using Railo.
(From the comments ...)
You might try setting loadColdFusionClassPath=true when you instantiate the javaLoader.

Java, using another java program in jar format

i want to embed an open source editor to my java desktop application. But i am not sure yet how to do it. I got jnlp web start and jar file to import library.
The program which will be imported is like below.
In fact i just need internal frames but if it is too completed i can embed whole program too.
I think about 3 options but don't know which one really works and which one is better.
Run jnlp webstart in java code
Run jar file in java code(non-executable jar)
Import jar and use its api (This is really what i need but i m not sure how to do this. I debugged the code to understand which frame works how but i have no experience about it and i found it very complicated)
Any advices how to solve this problem ?
Thanks,
Bilal
The picture just shows the view but there's more behind. You can't just embed the internal frames into you application and use the editors functionality. You'll need all the model, controller, support, ... classes too.
You may be lucky, that the main frame is just a simple container and you can "replace" it with your own container. But I not too optimistic. I don't think, that the editor has an API that allows integrating the internal frames into another container. So Option 3 would be the best but I think it's out of reach. Is it a common editor? Maybe more help is possible if you just tell us its name.

Categories