After upgrading the rgeo gem from 0.6.0 to 2.1.1, we've started to get 'LinearRing failed ring test' on certain geometries that never caused us problems before. (The geometry data is generated from external sources outside of our control, and stored in PostGIS table.)
rgeo initializer:
GEO_FACTORY = RGeo::Geographic.simple_mercator_factory
PROJECTION_FACTORY = GEO_FACTORY.projection_factory
RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
config.default = PROJECTION_FACTORY
end
Example code:
district = District.first
# Convert projected geometry to geographic geometry
geographic_geometry = GEO_FACTORY.unproject(district.geometry)
RGeo::Error::InvalidGeometry: LinearRing failed ring test
I also tried initializing the factory with the following options, but the errors persisted:
FACTORY = RGeo::Geographic.simple_mercator_factory(uses_lenient_assertions:true)
FACTORY = RGeo::Geographic.simple_mercator_factory(lenient_multi_polygon_assertions:true)
I've inspected some of these geometries where that are failing the LinearRing test, and it appears they are failing for a variety of reasons. Some possibly violate ring winding order, while with others I couldn't perceive the exact problem. But the point is, these are all geometries that we were able to work with before, and now are raising errors. I'd like to understand how we can return to the more lenient mode.
NOTES:
This is only happening on my Macbook (GEOS version 3.8.0), but not on our Linux production server (GEOS version 3.5.0)
REFERENCES:
https://github.com/rgeo/rgeo/issues/194
https://github.com/rgeo/rgeo-geojson/issues/33
This doesn't appear to be an issue with the rgeo gem but rather the underlying geos library on your mac.
There appears to be a difference in the way that geos 3.8.x (3.8.1 is the latest version in Homebrew circa 4/13/2020) and earlier versions of the geos library handle the is_simple calculation that determines Polygon validity. This affects any RGeo factory (most of them but not RGeo::Geographic.spherical_factory or RGeo::Cartesian.simple_factory) backed by the CAPI.
If you download version 3.5.x of geos from https://trac.osgeo.org/geos/ and build it with cmake (takes a while but installs cleanly) you should have consistent behavior between your production and local development environments.
If you were using the simple_mercator factory I doubt that differences in how spherical coordinates (implemented in pure ruby) are validated explain the differences in behavior that you see.
See this issue: https://github.com/rgeo/rgeo/issues/218
You most probably encountered this [1] bug. Reproducing needs Mac OS and shows the error you have:
RGeo::Error::InvalidGeometry (LinearRing failed ring test)
Issue is linked to pull request [2], which found the issue on Float vs BigDecimal difference. Somehow Floats are not so precise, when there are enough decimals included.
Side note: Pull request is only 26 days old, so it is still open, thus you'll need to build it from branch for the moment.
Source:
[1] https://github.com/rgeo/rgeo/issues/212
[2] https://github.com/rgeo/rgeo/pull/213
Related
I am stumbling my way through writing a dissector for our custom protocol in Lua. While I have basic field extraction working, many of our fields have scale factors associated with them. I'd like to present the scaled value in addition to the raw extracted value.
It seems to me tree_item:add_packet_field is tailor-made for this purpose. Except I can't get it to work.
I found Mika's blog incredibly helpful, and followed his pattern for breaking my dissector into different files, etc. That's all working.
Given a packet type "my_packet", I have a 14-bit signed integer "AOA" that I can extract just fine
local pref = "my_packet"
local m = {
aoa = ProtoField.new("AOA", pref .. ".aoa", ftypes.INT16, nil, base.DEC, 0x3FFF, "angle of arrival measurement"),
}
local option=2
local aoa_scale = 0.1
function m.parse(tree_arg, buffer)
if option == 1 then
-- basic field extraction. This works just fine. The field is extracted and added to the tree
tree_arg:add(m.aoa, buffer)
elseif option == 2 then
-- This parses and runs. The item is decoded and added to the tree,
-- but the value of 'v' is always nil
local c,v = tree_arg:add_packet_field(m.aoa, buffer, ENC_BIG_ENDIAN)
-- this results in an error, doing arithmetic on 'nil'
c:append_text(" (scaled= " .. tostring(v*aoa_scale) .. ")")
end
end
(I use ProtoField.new instead of any of the type-specific variants for consistency in declaring my fields)
The documentation for add_packet_field says that the encoding argument is mandatory.
There is a README in the source code that says ENC_BIG_ENDIAN should be specified for network byte-order data (mine is). I know that section is for proto_tree_add_item, but I traced the code far enough to see that add_packet_field ends up passing the encoding to proto_tree_add_item.
Basically, at this point, I'm lost. I did find this post from 2014 that suggested limited support for add_packet_field but surely by now something as basic as an integer value is supported?
Also, I do know how to declare a Field and extract the value after tree:add does the parsing; worst case I'll fall back to that, but surely there is a more expedient way to access the just-parsed value added to the tree?
Wireshark Version
3.2.4 (v3.2.4-0-g893b5a5e1e3e)
Compiled (64-bit) with Qt 5.12.8, with WinPcap SDK (WpdPack) 4.1.2, with GLib
2.52.3, with zlib 1.2.11, with SMI 0.4.8, with c-ares 1.15.0, with Lua 5.2.4,
with GnuTLS 3.6.3 and PKCS #11 support, with Gcrypt 1.8.3, with MIT Kerberos,
with MaxMind DB resolver, with nghttp2 1.39.2, with brotli, with LZ4, with
Zstandard, with Snappy, with libxml2 2.9.9, with QtMultimedia, with automatic
updates using WinSparkle 0.5.7, with AirPcap, with SpeexDSP (using bundled
resampler), with SBC, with SpanDSP, with bcg729.
Running on 64-bit Windows 10 (1803), build 17134, with Intel(R) Xeon(R) CPU
E3-1505M v6 # 3.00GHz (with SSE4.2), with 32558 MB of physical memory, with
locale English_United States.1252, with light display mode, without HiDPI, with
Npcap version 0.9991, based on libpcap version 1.9.1, with GnuTLS 3.6.3, with
Gcrypt 1.8.3, with brotli 1.0.2, without AirPcap, binary plugins supported (19
loaded).
Built using Microsoft Visual Studio 2019 (VC++ 14.25, build 28614).
Looking at the try_add_packet_field() source code, only certain FT_ types are supported, namely:
FT_BYTES
FT_UINT_BYTES
FT_OID
FT_REL_OID
FT_SYSTEM_ID
FT_ABSOLUTE_TIME
FT_RELATIVE_TIME
None of the other FT_ types are supported [yet], including FT_UINT16, which is the one you're interested in here, i.e., anything else just needs to be done the old fashioned way.
If you'd like this to be implemented, I'd suggest filing a Wireshark enhancement bug request for this over at the Wireshark Bug Tracker.
I'm using RSpec framework with capybara + eyes_selenium for visual testing, and i want to integrate mobile visual testing. i installed the appium_capybara, and it works with a remote appium server that functions as a node in my remote selenium hub.
So far it works great, I've managed to login to my iOs simulator and interact with the page. The problem is integrating this whole thing with applitools.
i'm using the gem eyes_selenium, but i can't seem to perform Eyes.open with my Appium::Capybara::Driver object, getting an exception that this driver is Unknown.
Eyes.open(app_name: 'Applitools', test_name: test_name, viewport_size: viewport_size, driver: Capybara.page.driver)
anyone managed to make it work ?
Looking at the source for the eyes_selenium gem, the only place that error can come from is from the eyes_driver method - https://github.com/applitools/eyes.sdk.ruby/blob/master/lib/applitools/selenium/eyes.rb#L39 - which is implemented as below
def eyes_driver(driver, eyes = nil)
if driver.respond_to? :driver_for_eyes
driver.driver_for_eyes eyes
elsif defined?(::Capybara::Poltergeist) && (driver.is_a? ::Capybara::Poltergeist::Driver)
Applitools::Poltergeist::Driver.new(eyes, driver: driver)
else
unless driver.is_a?(Applitools::Selenium::Driver)
Applitools::EyesLogger.warn("Unrecognized driver type: (#{driver.class.name})!")
is_mobile_device = driver.respond_to?(:capabilities) && driver.capabilities['platformName']
Applitools::Selenium::Driver.new(eyes, driver: driver, is_mobile_device: is_mobile_device)
end
raise Applitools::EyesError.new "Unknown driver #{driver}!"
end
end
At a first glance the else section of that looks fully broken to me (why create a new instance of Applitools::Selenium::Driver just to then raise an error?). However, that leaves only a few possibilities for why it's not working for you,
Appium::Capybara::Driver is not a driver type supported by the eyes_selenium gem
You're not requiring the files needed to patch Appium::Capybara::Driver to be supported, such as 'applitools/capybara', although after a quick look through the eyes_selenium code I don't think it adds the driver_for_eyes method to any ancestor class of Appium::Capybara::Driver (does patch Appium::Driver though) so #1 is probably more likely.
How would one go about making sure that a .love file only runs if the current version of LOVE2D is better than a given minimum version? Without some sort of check, the resulting errors can be obscure and seemingly unrelated to the LOVE version, requiring the user to waste a lot of time trying to diagnose issues based on misleading errors.
You can add t.version = "0.8.0" to your conf.lua and it will warn the user if he is using a version other than 0.8.0. You shouldn't block mismatched versions, you should warn them.
Here's an example of conf.lua:
function love.conf(t)
t.title = "Game title"
t.author = "Your name"
t.version = "0.8.0"
end
Here's the wiki article on conf.lua.
I recently had to move my site from one server to another and it appears Fred's 3Drotate script creates files that have Imagemagick settings in them instead of image data. When I first ran the script I received the following error:
expr: warning: unportable BRE: `^[0-9][0-9]*$': using `^' as the first character of the basic regular expression is not portable; it is being ignored
expr: warning: unportable BRE: `^[+-][0-9][0-9]*$': using `^' as the first character of the basic regular expression is not portable; it is being ignored
expr: warning: unportable BRE: `^[0-9]*[\\.][0-9]*$': using `^' as the first character of the basic regular expression is not portable; it is being ignored
expr: warning: unportable BRE: `^[+-][0-9]*[\\.][0-9]*$': using `^' as the first character of the basic regular expression is not portable; it is being ignored
I was able to resolve this by removing each instance of the '^' character. The script runs and it creates a file of a few hundred KB, but the contents appear to be a configuration such as:
id=MagickCache
quantum-depth=16
class=DirectClass colors=0 matte=False
columns=500 rows=500 depth=8
colorspace=sRGB
compression=JPEG quality=75
units=PixelsPerInch
resolution=72x72
page=500x500+0+0
rendering-intent=Perceptual
gamma=0.454545
red-primary=0.64,0.33 green-primary=0.3,0.6 blue-primary=0.15,0.06
white-point=0.3127,0.329
date:create=2012-08-10T20:44:21-07:00
date:modify=2012-08-10T20:44:21-07:00
jpeg:colorspace=2
jpeg:sampling-factor=2x2,1x1,1x1
Any ideas? I'm running imagemagick version 6.7.8-9 which is newer than what was on my original server, however I don't know which version that was.
Update:
I'm on a CentOS box using 3DRotate revised by Fred on 3/11/10. ImageMagick is version 6.7.8-9 whereas my old server, also CentOS was using version 6.7.6-0.
Fred's 3Drotate script still works fine for me. I have no reason to complain.
This is on Mac OS X Lion, with Bash version GNU bash, Version 4.2.37(2)-release....
You are strongly advised to re-download the script and try again. If you want to report a bug, you should give info about your OS, your Bash and your ImageMagick versions...
Oh, and see also this page, which states...
...you need ImageMagick v6.3.5.0 or higher for the script to work,
...gives some hints about troubleshooting and
...tells you the eMail address of the author so you can contact him to discuss your problems.
With recent changes to ImageMagick between IM 6.7.6.7 and IM 6.7.8.3 for colorspace changes and grayscale becoming linear, I have had to go through recently all my scripts and make appropriate changes. I am only part way through my scripts as of this date, but have fixed about 1/3 to 1/2, but 3Drotate did not need any changes since the last one on 11/26/2011. But your version is to old, so you will need to get an update. The problems you seem to have may or may not be related. But appear to be related to the unix utility expr. I would make sure that you have a current version of that installed. The following works perfectly fine for me on both IM 6.7.6.0 and 6.7.8.9 on my Mac OSX Snow Leopard
3Drotate pan=45 tilt=45 auto=zc mandril.jpg mandril_test.jpg
The first question I would ask is what was your exact command line. As you can see the arguments are a bit different from my other scripts as they include equal signs.
If you still have trouble, report them to me or on the ImageMagick Discourse forum at http://www.imagemagick.org/discourse-server/viewforum.php?f=1
Fred
I want to use cache-money but I don't want to start automatically caching everything (I'm working with a large production app, terabytes of data etc). How do I use it for only the models that I specify? Right now I've got:
# initializers/cache_money.rb
require 'cache_money'
config = (cfg = YAML.load(IO.read(File.join(RAILS_ROOT, "config", "memcached.yml"))))[RAILS_ENV] || cfg["defaults"]
$memcache = MemCache.new(config)
$memcache.servers = config['servers']
$local = Cash::Local.new($memcache)
$lock = Cash::Lock.new($memcache)
$cache = Cash::Transactional.new($local, $lock)
and then in the model I want to cache with cache-money:
# my_model.rb
class MyModel < ActiveRecord::Base
is_cached :repository => $cache
# ...
end
But this doesn't work; the call to is_cached gives the following error: NoMethodError: undefined method `create' for Config:Module
Any ideas? Failing that, is there anywhere I can go for help with cache-money? I couldn't find a mailing list or anything.
I think this is a bug in the cache_money code.
There are forks available on github that fix this bug, eg:
http://github.com/quake/cache-money
The fix can be seen with this commit:
http://github.com/quake/cache-money/commit/54c3d12789f31f2904d1fe85c102d7dbe5829590
I've just experienced the same problem trying to deploy an application. Running on my development machine it was fine, but it failed with this error on the production machine.
Apart from the architecture (OSX vs CentOS) the only difference i could see was that the ruby versions were different (1.8.6 p114 vs 1.8.6 p0). After upgrading the server to the latest 1.8 version (1.8.7 p160) this error went away.