crotwell / seisFile

A library for reading and writing seismic file formats in java.
GNU Lesser General Public License v3.0
27 stars 20 forks source link

Additional parameter in FDSNStationQueryParams #25

Closed andreabono closed 2 years ago

andreabono commented 2 years ago

Hello!!
I wrote the following code to read some stationXML info via an FDSNStationQuerier:

FDSNStationQueryParams queryParams = new FDSNStationQueryParams();
if (ChannelsList != null) queryParams.appendToChannel(ChannelsList);
if (lat != null) queryParams.setLatitude(lat.floatValue());
if (lon != null) queryParams.setLongitude(lon.floatValue());
if (delta_min != null) queryParams.setMinRadius(delta_min.floatValue());
if (delta_max != null) queryParams.setMaxRadius(delta_max.floatValue());
...
FDSNStationQuerier querier = new FDSNStationQuerier(queryParams);
FDSNStationXML xml = querier.getFDSNStationXML();
....

It works pretty fine, but now I need to add a "custom" parameter; so I'm trying:

queryParams.setParam("authoritative", "any");

but I'm facing the "protected" attribute on setParam.
So, what can I do to add a custom parameter?

crotwell commented 2 years ago

Humm, this is not a use case I had considered. Long term I can make those methods public and put out a new release.

But in the short term, you might be able to create your own subclass of FDSNStationQueryParams and access the setParam methods from within it.

Alternatively, and maybe easier, you can use the getParams() method to get the params as a HashMap and add your custom parameter manually. Something like:

queryParams.getParams().put("authoritative", "any");

Let me know if these work for you.

andreabono commented 2 years ago

THANKS A LOT!!!!!!!! The second solution is ok for me.
I tried the first one before opening this issue, but I could not figure out how to get to the point. Sometimes things are easier than one can expect.
Thanks again!!