Cesium is not extensiable?How to solve this? - cesiumjs

dev environment:vite2+vue3+typescript
import Ceisum by vite-plugin-cesium
code like this can't pass
Cesium.GoogleImageryProvider = GoogleImageryProvider

Related

Not able to click on the button using Selenium

<button class="css-obkt16-button" type="button"><span class="css-1mhnkuh">Download CSV</span></button>
I am trying to click on the highlighted button 'Download CSV' having the above HTML code and save the csv file at some particular location, but I am not able to do so. The file is getting downloaded in Downloads folder.
My python code:
def scrape_data():
DRIVER_PATH = r"C:\chrome\chromedriver.exe"
driver = webdriver.Chrome(DRIVER_PATH)
driver.get('Link to the dashboard')
time.sleep(20)
buttons = driver.find_element(By.XPATH,"//button/span[text()='Download CSV']")
time.sleep(5)
driver.execute_script("arguments[0].click();", buttons)
driver.quit()
So please suggest a way to search via the button text) and save the file to a particular location??
To download the file on specific location you can try like blow.
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_experimental_option("prefs", {
"download.default_directory": r"C:\Data_Files\output_files"
})
s = Service('C:\\BrowserDrivers\\chromedriver.exe')
driver = webdriver.Chrome(service=s, options=options)
You should not use hardcoded sleeps like time.sleep(20). WebDriverWait expected_conditions should be used instead.
Adding a sleep between getting element and clicking it doesn't help in most cases.
Clicking element with JavaScript should be never used until you really have no alternative.
This should work in case the button you trying to click is inside the visible screen area and the locator is unique.
def scrape_data():
DRIVER_PATH = r"C:\chrome\chromedriver.exe"
driver = webdriver.Chrome(DRIVER_PATH)
wait = WebDriverWait(driver, 30)
driver.get('Link to the dashboard')
wait.until(EC.element_to_be_clickable((By.XPATH, "//button[contains(.,'Download CSV')]"))).click()

features at "wrong" position / flipped after EPSG:31287 -> EPSG:4326 transformation

I am currently trying to convert WFS2/GML3.2 data in EPSG:31287 to geojson using openlayers 6.15.1. For geojson I am trying to convert it to EPSG:4326/WGS84 using the following Typescript snippit:
import { WFS } from 'ol/format'
import { GeoJSON } from 'ol/format'
import { register } from 'ol/proj/proj4';
import * as proj4x from "proj4";
const proj4 = (proj4x as any).default;
// define EPSG:31287
proj4.defs('EPSG:31287', '+proj=lcc +lat_0=47.5 +lon_0=13.3333333333333 +lat_1=49 +lat_2=46 +x_0=400000 +y_0=400000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.42319999999019 +units=m +no_defs +type=crs');
register(proj4);
// initialize WFS parser
const parser = new WFS({featureNS: 'http://mapserver.gis.umn.edu/mapserver', version: '2.0.0'
const data = '...some wfs 2.0.0 response containing GML3.2 data...';
// read the features
const wfsFeatures = parser.readFeatures(data);
// and immediatly write it as geojson, transforming it from EPSG:31287->EPSG:4326
const geoJsonString = new GeoJSON().writeFeatures(wfsFeatures, {
featureProjection: 'EPSG:31287',
dataProjection: 'EPSG:4326'
});
However it seems something is going wrong during the re-projection. Not only is the geometry at the wrong location, it also seems rotated/flipped:
[1]: https://i.stack.imgur.com/7GV1o.png
Interestingly, no matter which output-transformation I choose (when exporting to GML3.2 instead of GeoJSON, tried 4326 and 3857), the result always looks the same in QGIS. Only when specifying EPSG:31287 everywhere the result is correct (but of course in the wrong projection), most likely because openlayers detects it actually can avoid re-projection between equal projections.
Any idea what is going on here? Some pointers would really help.

How to import nwjs in ES6/typescript?

In ES6, I want to use this sample code in angular 1.6 code.
var win = nw.Window.get();
win.on('new-win-policy', function(frame, url, policy){
policy.forceNewWindow();
});
These are the steps I did,(updated package.json)
npm install nwjs
in code,
import nw from 'nwjs'; //I guess this is not correct
please help what am I doing wrong.
did you try ?
import nw = require('nwjs');
not sure if this works in angular project but this is how i use it in Node + Typescript.
This works for me:
import {} from 'nw.js';

How to get the current URL from Chrome using pywinauto 0.6

In this question How can I get a url from Chrome by Python?, it was brought up that you could grab the url from python in pywinauto 0.6. How is it done?
Using inspect.exe (which is mentioned in Getting Started) you can find Chrome's address bar element, and that its parameter "value" contains the current url.
I found two ways to get this url:
from __future__ import print_function
from pywinauto import Desktop
chrome_window = Desktop(backend="uia").window(class_name_re='Chrome')
address_bar_wrapper = chrome_window['Google Chrome'].main.Edit.wrapper_object()
Here's the first way:
url_1 = address_bar_wrapper.legacy_properties()['Value']
Here's the second:
url_2 = address_bar_wrapper.iface_value.CurrentValue
print(url_1)
print(url_2)
Also if protocol is "http" Chrome removes "http://" prefix. U can add sth like:
def format_url(url):
if url and not url.startswith("https://"):
return "http://" + url
return url

How to convert a web html to pdf with pyqt5

last year i converted html to pdf with pyqt4 succesfully.. but with pyqt5 i lost 2 days and i´m frustrated..
This is my code:
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebKitWidgets import QWebView
from PyQt5.QtPrintSupport import QPrinter
from PyQt5.QtCore import QUrl
app = QApplication(sys.argv)
web = QWebView()
web.load(QUrl("https://www.google.com"))
printer = QPrinter()
printer.setPageSize(QPrinter.A4)
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName("out.pdf")
def convertIt():
web.print_(printer)
print ('Pdf generado')
QApplication.exit()
QObject.connect(web, SIGNAL("loadFinished(bool)"), convertIt)
app.exec_()
And i have one "QOject no have attribute "connect"... i know is something about the signals, that changed from pyqt4 to pyqt5, but i have no idea to code it.. thanks in advance.
This should be web.loadFinished.connect(convertIt) as per the PyQt docs about signals/slots.