How to use "using static" with generic classes?

U

Ufuk Can İşbildi

Guest
Ufuk Can İşbildi Asks: How to use "using static" with generic classes?
C# has an using static directive since C# 6.0 which is allows to includes more specific things (like classes, interfaces etc.) than namespaces. Well, I tried to include generic type class (System.Collections.Generic.List<T> to be clear). I used using static System.Collections.Generic.List<T>; and program failed. Is there a way to include generic type classes by using using static directive?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.
 

Unreplied Threads

[Solved] Is it possible to append layers to a kml file in R?

karpfen Asks: Is it possible to append layers to a kml file in R?
I'm trying to create a kml file containing two layers to display in Google Earth.

Here's a small example of what I've tried:

Code:
library(sf)

poly <- st_as_sf(st_as_sfc(
  "POLYGON ((-59.6354 5.0372, -59.3598 5.0372, -59.3598 5.3175, -59.6354 5.3175, -59.6354 5.0372))"
  , crs = 4326
))
pt <- st_as_sf(st_as_sfc(
  "POINT (-59.6354 5.0372)"
  , crs = 4326
))

# Using GeoPackage, it works as expected
st_write(poly, "test.gpkg", layer = "outlines")
st_write(pt, "test.gpkg", layer = "points", append = TRUE)

# Using KML produces an error
st_write(poly, "test.kml", layer = "outlines")
st_write(pt, "test.kml", layer = "points", append = TRUE)
# Error in CPL_write_ogr(obj, dsn, layer, driver, as.character(dataset_options),  :
#   Cannot append to existing dataset.

I still hope that it is possible to achieve a two-layer kml with R, though, since it's also possible to just piece one together using a text editor:

desired_output.kml:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns=http://www.opengis.net/kml/2.2>
<Document id="root_doc">
<Folder><name>outlines</name>
  <Placemark>
<Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
      <Polygon><outerBoundaryIs><LinearRing><coordinates>-59.6354,5.0372 -59.3598,5.0372 -59.3598,5.3175 -59.6354,5.3175 -59.6354,5.0372</coordinates></LinearRing></outerBoundaryIs></Polygon>
  </Placemark>
</Folder>
<Folder><name>points</name>
  <Placemark>
      <Point><coordinates>-59.6354,5.0372</coordinates></Point>
  </Placemark>
</Folder>
</Document></kml>

This is compatible with Google Earth and does exactly what I want. Is there any way to achieve this using R?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, solveforum.

[Solved] Passing Geometry object to processing tool instead of Layer

  • Kadir Şahbaz
  • Geography
  • Replies: 0
Kadir Şahbaz Asks: Passing Geometry object to processing tool instead of Layer
In ArcPy, you can pass a geometry object as parameter to geoprocessing tool:

Code:
import arcpy

coordinates = [[20, 30], [30, 30], [30, 20], [20, 20]]
array = arcpy.Array([arcpy.Point(x, y) for x, y in coordinates])

# Create a polygon geometry object using the array object
boundary = arcpy.Polygon(array, arcpy.SpatialReference(4326))

arcpy.Clip_analysis('c:/data/rivers.shp', 
                     boundary, # <- GEOMETRY OBJECT
                    'c:/data/rivers_clipped.shp')

I have a polygon geometry and a layer. I want to clip the layer by the polygon geometry using PyQGIS. Normally, I make a new layer, add the geometry to the layer and use it in processing.run as follows:

Code:
coordinates = [QgsPointXY(20, 30), QgsPointXY(30, 30),
               QgsPointXY(30, 20), QgsPointXY(20, 20)]
geometry = QgsGeometry.fromPolygonXY([coordinates ])

temp_layer = QgsVectorLayer(f"Polygon?crs=EPSG:4326", "TEST", "memory")

feature = QgsFeature()
feature.setGeometry(geometry)
temp_layer.dataProvider().addFeatures([feature])
temp_layer.updateExtents()

LayerA = iface.activeLayer()

result = processing.run("native:difference",
                        {'INPUT': LayerA,       # <- QgsVectorLayer
                         'OVERLAY': temp_layer, # <- QgsVectorLayer
                         'OUTPUT':'TEMPORARY_OUTPUT'})

But I would like to avoid making a new layer for one geometry. I tried passing a geometry to processing.run, but it obviously didn't work:

Code:
result = processing.run("native:difference",
                        {'INPUT': LayerA,       # <- QgsVectorLayer
                         'OVERLAY': geometry,   # <- QgsGeometry ?
                         'OUTPUT':'TEMPORARY_OUTPUT'})

How can I pass a geometry object to a processing tool without making a new layer for the geometry? Is that possible in PyQGIS?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, solveforum.

If I have a mixture of potassium hydroxide and sodium hypochlorite, what will be the result of adding citric acid or ascorbic acid?

CJ W Asks: If I have a mixture of potassium hydroxide and sodium hypochlorite, what will be the result of adding citric acid or ascorbic acid?
I have a cleaning chemical that is 10% potassium hydroxide (KOH) and 5% sodium hypochlorite (NaClO). What is the result if I add citric acid (C6H8O7) or ascorbic acid (C6H8O6)? My goal is to neutralize the high pH of the potassium hydroxide without creating dangerous byproducts. I do not have a background in chemistry. How do I determine the result of the mass balance equation?

KOH + NaClO + C6H8O7 -> ?
KOH + NaClO + C6H8O6 -> ?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Canonical transformation of multiple-modes entanglement

  • Daniele Cuomo
  • Physics
  • Replies: 0
Daniele Cuomo Asks: Canonical transformation of multiple-modes entanglement
This question is a continuation of this previous one.

I cite the part I would like to extend.

[...] one can perform a canonical transformation that would eliminate the photon modes from the Hamiltonian, replacing them by "effective coupling" constant, as if the qubits are coupled directly. (Sometimes one speaks of integrating out the photon mode - a matter of background/method.)

It refers to a superposition among two qubits and a photon mode.

I would like to understand how such a canonical transformation works.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Is the cosmic background radiation random and Kolmogorov complexity

  • mathoverflowUser
  • Physics
  • Replies: 0
mathoverflowUser Asks: Is the cosmic background radiation random and Kolmogorov complexity
In the article https://arxiv.org/pdf/physics/0510102.pdf the idea arises that if there was a Creator of the Universe and wanted to send us a message, then the "right" place to do it, would probably be the the cosmic background radiation. One such message might simply be: "This message is not random.". How do we measure randomness of messages? Kolmogorov suggested the Kolmogorov complexity of a string, which is the shortest computer program to produce that string. If a string is random, then its Kolmogorov complexity would be high, or at least the size of the string. Now in reality this function is not computable, so one possible approximation is to use gzip, zip or any other compression algorithm to approximate the complexity. My question is this: Has this question been investigated? (If so, what was the conclusion? :) ) When would a gzipped version hint to a non-random message? (So does it have to be like half the message length or when would it count as non - random?)

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Who gave right hand thumb rule for circular loop of current conducting wire?

  • Level1
  • Physics
  • Replies: 0
Level1 Asks: Who gave right hand thumb rule for circular loop of current conducting wire?
To find magnetic field due to current conducting straight wire we have Maxwell's Right hand thumb rule, Which says "Put your right hand thumb in the direction of current then curled fingers shows the direction of field" I can see that this can be used for a current conducting loop but there is another version for a loop.

To find magnetic field due to a current conducting loop is given by another right hand thumb rule. The rule says "curl your fingers of right hand along the direction of current then thumb gives the direction of field"

My question is that who gave the second rule. Is it given by Maxwell himself or someone else? Is it modified version of first stated rule?. Who should I credit for the second rule?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Difference between reference frame and coordinate system

  • imbAF
  • Physics
  • Replies: 0
imbAF Asks: Difference between reference frame and coordinate system
In wikipedia, regarding this topic, different examples are given as to why a reference frame and coordinate system are NOT the same thing (https://en.wikipedia.org/wiki/Frame_of_reference). Example from J.D Norton:

More recently, to negotiate the obvious ambiguities of Einstein’s treatment, the notion of frame of reference has reappeared as a structure distinct from a coordinate system.

I am trying to understand the different definition and I have come up with the following understanding, for which I want to know whether is correct or faulty.

First off all I consider that a difference between the two exists. For once a coordinate system is a mathematical/abstract concept while the reference frame is something grounded in physics/or physical.

I would consider a coordinate system of whatever kind as "tool" (for lack of better words), which assigns a set of numbers to each point in space.

The reference frame is an "entity" (for lack of better words again), which is correlated or related to a physical location/body etc, to which a coordinate system of whatever kind is attached to, giving to the observer, in this physical location (one can say the observer is at rest in this reference frame) the possibility to assign a location and a time to an event E.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.