The location of .config for geotiler on Windows - matplotlib

I'm working in jupyter notebook on Windows with matplotlib basemaps and I want to use geotiler with the basemaps. I'm writing a program and as part of it, it will generate a map and plot data points on it. However, the maps that my code generates often are over a small part of the world and have no defining features. My solution was to import the geotiler library and display it over the map with an alpha so the maps generated would be identifiable. However, when I use the geotiler.Map() function, I get a message saying that the configuration file does not exist.
The code and the error message
How do I locate the .config folder on Windows, if it exists, and where should I create it if it doesn't? I already tried my user folder but that didn't seem to work. Thanks in advance.

Figured it out.
The read_config() method in the source code tries to get the HOME environment variable, which for Windows is blank, and appends the path for the config to that. Importing os and manually setting the HOME variable to wherever you placed your .config folder seems to do the trick. You can do this with os.environ['HOME'] = 'C:\Users\YourName'.

Related

Add file from working directory into code

Is there a 'shortcut' way to add a file in the code in pycharm? I have this structure everything is in a folder called 'myFolder' that you cannot see on the picture.
Using e.g. Visual Code I was able to reference the file like this:
df = pd.read_csv('in/test_DS.csv', sep=';', encoding='iso-8859-1')
is there a similar way in Pycharm or do I have to do full reference?
There is currently no such feature, but there is a corresponding feature request https://youtrack.jetbrains.com/issue/PY-33254 which is In Progress and expected to be in 2019.2 version.

Windows 10 Phone Store Logo Error

I created my app in Unity and after publishing for Android and iPhone, i'm trying to get the Windows 10 Phone version published.
I added my image assets to Unity, but when I open the generated project in Visual Studio, I get the following error in the Visual Assets tab:
A mixture of mages with and without the "scale" or "targetsize" qualifiers exists in the project for the logical name "Assets\StoreLogo.png" for the "Scale 100 50x50 px" image. All the other images are importing correctly.
The only related question I see on SO is:
Adding all images to the Package.AppXManifest results in a compiler warning
but in my case it is an error instead of a warning
The image with the correct scale does exist in my Assets folder, even though I had to add it manually:
Just wondering if anyone knows how to debug/fix this? rename the image, create a new image etc? ie: Why the 50x50px scale 100 image is not working as expected.
My Unity version is 5.3.4, Visual Studio 2015
It's basically saying that StoreLogo.png will be ignored since there is a file with same name plus the scale qualifier: StoreLogo.scale-100.png.
When packaging the two files are considered the same, but to prevent unexpected behavior you should delete one of them. It basically means that if you change StoreLogo.png, but not StoreLogo.scale-100.png, the output will not change since the packaging process will always ignore the StoreLogo.png file.
I would rename the StoreLogo.png file to just Logo.png and keep them both. But you can also delete one of them and get rid of the warning.
Seems that the order of adding the PNG to the project matters. So, for the StoreLogo you would need to add the 50x50 resolution PNG first.
And if you are using version control, make sure it is checked-in.

How to build with a custom eglfs cursor atlas?

I'm trying to change the eglfs mouse cursor graphics for my embedded linux QT application (QT5.5). I have the new cursor atlas PNG and the new JSON descriptor file, but the documentation is rather vague:
".. a custom cursor atlas can be provided by setting the QT_QPA_EGLFS_CURSOR environment variable to the name of a JSON file. The file can also be embedded into the application via Qt's resource system."
I'd prefer to keep everything within the resource system if possible but I can't work out how to do it.. do I need a specific qrc file containing the path to the JSON file? I assume that the PNG file would also need to be added as a resource so that it gets built into the application?
If adding it via the resource system is a bad idea where's the correct place to set the QT_QPA_EGLFS_CURSOR environment variable? I'm currently specifying the platform on the command line via "-platform eglfs"; will this be ok or will I need to set the platform to eglfs in the build?
After much trial, error and digging around I have found the solution that I was looking for within the resource system.
Create a new resource file called "cursor.qrc", the contents of which needs to be two lines:
path/to/your/custom-cursor-atlas.png
cursor.json
The first line (path to your cursor atlas) must be relative to your resource directory.
You then need to put the JSON file (contents as described in the documentation) in the root of your resource directory. It must be called "cursor.json", and its image location line must must match the location in your new resource file and be of the format:
"image": ":/path/to/your/custom-cursor-atlas.png",
This will then include your cursor atlas in resources, and Qt will find it when your application starts.
Run time solution example:
export XDG_RUNTIME_DIR=~
export QT_QPA_EGLFS_CURSOR=~/cursor.json
In the cursor.json:
"image": "cursor.png",
Put your custom cursor.png atlas into your home dir (~) then run the Qt app from there.

GEPlugin does not load KML files on VB.NET

I have developed an app using the GEPlugin located at https://code.google.com/p/winforms-geplugin-control-library/.
I use the GEWebBrowser and the GETreeView, and both works nicely.
I only load local kml files on the controls, so the way to do this, is to copy the "KML_Samples.kml" file into the webroot directory, and call the function as follows:
GeWebBrowser.FetchKml(http://localhost:8080/KML_Samples.kml)
Each time I call this method, the event GeWebBrowser_KmlLoaded is launched in the correct way.
However, I have checked lately that this works fine for the two or three first kml files loaded. After this two or three files, when I try to load a new kml file, I can see that the the KML_Samples.kml file has been updated, but the GeWebBrowser_KmlLoaded event IS NOT LAUNCHED!
I have tried to execute the app step by step setting a breakpoint on the line
GeWebBrowser.FetchKml(http://localhost:8080/KML_Samples.kml)
and in this case, I can load the kml files!!.
I have tried to execute some code after this line in order to execute all the pending events, with the following line:
Application.DoEvents()
However, this has not the expected result, and the trouble remains: I'm only able to load the two or three first kml files.
I wonder if something is missing by my side using this control, but I have not found anything on the documentation that could help me.
If anyone could help me with this issue, I would be very thankful .
I answer my own question.
I have detected the GEControl does not works fine with the built-in server. I can load local kml files by sopying them at webroot\KML_Samples.kml, but this only works for the first two or three files to be loaded.
For the following kml files, it doesn't work. I suppose there is some mistake inside the control, so I'm going to develop all the code that load the kml file into a TreeView (I'll try to use the KmlTreeView), and load all the separated points of each kml file into the plugin.

Unraveling the confusion about Embedded Resources

EDIT: Read answer number 1 from Tim Schmelter and then use this question for examples of how to embed resources and access them at runtime.
The subject of embedded resources comes up a lot, especially with people asking how to access the embedded files at runtime. Things get more confusing because Visual Studio gives you 2 different ways of embedding a resource, and different ways of accessing those resources at runtime. The problem is that depending on which method you used to embed the resource, the method you’re trying to use to access the file at runtime might not work. This post is an attempt to clear up all the confusion that I see out there, but I also have a question that nobody can seem to answer factually: Why is the size of my compiled program TWICE the size of the embedded resource (sometimes)? For example if I embed a 20MB file into my project, why does my program compile to 40MB? I haves asked this question in the past and nobody was able to reproduce my results. I found that the reason they were not able to reproduce was because they were embedding the file in a different way. See here:
Method 1:
Double-click on My Project to open the property pages and go to the Resources Tab. Now click Add Resource > Add Existing File. Browse to the file you want to embed. For this example I’m using an executable. You will now see your file on the Resources Tab:
You will also see that a folder named Resources was created under your project and the embedded file has been placed in this folder:
EDIT: THIS NEXT STEP WAS THE PROBLEM. TURNS OUT THAT WHEN YOU ADD A FILE VIA THE RESOURCES TAB YOU SHOULD NOT SET THE BUILD ACTION TO EMBEDDED RESOURCE. Counter intuitive to say the least!
Now with the file selected, look down at the properties window for the file and change the build action to Embedded Resource: (this step should ONLY be performed when you add a file via method 2).
Now compile your program. You will see that the size of your compiled program is at least double the size of your embedded resource. This does not happen with method 2. See here:
Method 2:
Right-click on your project name and choose Add > Existing Item. Browse to your file, and this time you will notice that while it was indeed placed under your project, there was no Resources folder created:
Now once again select the file and change the Build Action to Embedded Resource and compile. This time the size of the compiled program will be as you expected - about the size of the embedded file and not double the size as with method 1.
Which method you use to embed your file will determine which method you can use to access the file at runtime. For method 1 this is very simple, all you have to do is:
My.Computer.FileSystem.WriteAllBytes(Path, My.Resources.ResourceName, Append)
Where Path is the location and name for the file you want to save on the harddrive, ResourceName is the name of the embedded resource that you see in the project window (minus any extension), and Append is whether or not you want to create a new file or overwrite an existing file. So for example, using test.exe from the above images, I could save that file to the C drive like this:
My.Computer.FileSystem.WriteAllBytes(“C:\test.exe”, My.Resources.test, False)
Couldn’t be easier.
Method 2 however doesn’t appear to give you access to My.Resources so it gets a little more complicated. You have to create a Stream to hold the resource, put the stream into a byte array, then write the bytes out to the file system. The simplest way I have found to do this is like this:
Using s As Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(Project.ResourceName)
Dim bytes(s.Length) As Byte
s.Read(bytes, 0, bytes.Length)
File.WriteAllBytes(OutputFile, bytes)
End Using
With this method ResourceName must contain the file extension AND project name so using our example from above we can just do:
Using s As Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(WindowsApplication1.test.exe)
Dim bytes(s.Length) As Byte
s.Read(bytes, 0, bytes.Length)
File.WriteAllBytes(“C:\test.exe”, bytes)
End Using
Text-based files are a little different:
Dim output As String
Using sr As StreamReader = New StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(WindowsApplication1.test.txt))
output = sr.ReadToEnd()
End Using
Using sw As StreamWriter = New StreamWriter(“C:\test.txt”)
sw.Write(output)
End Using
Having struggled with this in the past I hope this will help someone. And if you think you can explain factually why method 1 of embedding a resource bloats my compiled program to double its size, I would really appreciate it.
I assume that Method 1 is adding the files twice.
http://www.vbdotnetforums.com/vb-net-general-discussion/42670-visual-basic-net-2008-get-resource-file-io-stream.html#post121923
At least that is the conclusion of the thread above.
Quote:
You went to the Resources page of the project properties and added the files there, right? You then went into the Solution Explorer and change the Build Action of the files to Embedded Resource, right? That's why you were doubling the file size: you were adding each file twice.
There are two different ways to add resources: on the Resources page of the project properties and in the Solution Explorer. You do NOT do both. If you want to use GetManifestResourcestream then you do NOT use the Resources page. You add the files to the project in the Solution Explorer manually, then you set the Build Action to Embedded Resource.
In future, do one or the other, not both.
Add a file to the Resources page of the project properties and then access it via My.Resources. This will automatically add the file to the project in the Solution Explorer but the Build Action will be None and it should be left that way.
Add the file to the project in the Solution Explorer by using Add New Item or Add Existing Item. Set the Build Action of the file to Embedded Resource and then access the resource using GetManifestResourceStream.
Just an update for anyone who wants to use this code. The code actually writes one additional byte to the file due to zero-based declaration of the byte array.
To get an exact copy of the original file change the code to:
Using s As Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(WindowsApplication1.test.exe)
Dim bytes(s.Length-1) As Byte
s.Read(bytes, 0, bytes.Length)
File.WriteAllBytes(“C:\test.exe”, bytes)
End Using