What is the Mapbox Expression for "multiply"? - mapbox-android

Mapbox's Android SDK has an Expression for Expression.division(), but what is the static method for multiplication?
I tried looking for the following static methods:
Expression.multiply()
Expression.multiplication()
Expression.times()
Expression.multiple()
But none of these exist.

To multiply two numbers use Expression.product()

Related

C++ Function does not take 2 arguments

I'm following a tutorial on creating a video game using C++. And I've got stuck on this step:
spriteBg -> setAnchorPoint(0,0);
I've got an error of: Function does not take 2 arguments
But anchor points are usually two digits pair (x,y) or Vec2::ZERO according with the docs, so what it's wrong with this line?
The guy on the tutorial has a red curvy line under the second 0 as well I have that red line under my second zero in setAnchorPoint(0,0), nevertheless he can build the project without errors but I can't due this error of 2 arguments.
He is using Visual Studio 2012 and I'm using Visual Studio 2013 for what it's worth. The Project was generated with Cocos2d.
This is the whole method.
bool HelloWorld::init()
{
if ( !Layer::init() )
{
return false;
}
auto spriteBg = Sprite::create("images/bg.png");
spriteBg ->setAnchorPoint(0,0);
spriteBg ->setPosition(0,0);
addChild(spriteBg , 0);
return true;
}
This is the whole error:
error C2660: 'cocos2d::Sprite::setAnchorPoint': function does not take 2 arguments
So far the same result with 5 approaches:
spriteBg ->setAnchorPoint(0,0);
spriteBg ->setAnchorPoint({0,0});
spriteBg ->setAnchorPoint(Vec2::ZERO);
spriteBg ->setAnchorPoint(Vec2(0,0));
spriteBg ->setAnchorPoint(Point(0,0));
This is the tutorial and this particular step is at 18:27. The tutorial is in Spanish but you clearly can see the guy coding and is just a few lines.
https://www.youtube.com/watch?v=v7d3ic_lmGw
Greetings.
Not sure what the problem is without the exact error message, but if you say it takes Vec2::ZERO maybe try:
spriteBg -> setAnchorPoint(Vec2(0,0));
As clearly mentioned in your error :- error C2660: 'cocos2d::Sprite::setAnchorPoint': function does not take 2 arguments
it takes only one argument of 'Vec2' type.
Try spriteBg -> setAnchorPoint(Vec2(0,0));
Jump to the definition of sprite and look at the function definition for setAnchorPoint. Depending on what version of Cocos2D-x you're using I know for a fact that setAnchorPoint takes a Vec2 object.
The parameter of setAnchorPoint in cpp should be a Point(Vec2). Of course you will get the error if the parameters are two number.
It is easy to understand the error by checking the declaration of the function.
Not sure if this works completely, try using:
sprite->setAnchorPoint(ccp(0,0));

freeimage 3.17 library build failing on Mac OS X: fails with C++11 narrowing error... any ideas?

With not having any understanding of C++ (I'm teaching myself Swift), I'm struggling a bit to get around this one - but ideally would love to be able to expose some of the functionality in the FreeImage library in my project.
It appears that only one module is generating any errors: dcraw_common.cpp - and the lines in error are those from the following entry list where there is a value of 0x80 or above. From the investigations I've done, it would appear that these values are too large for a signed char (max 128?), yet the list also includes negative numbers, and so it can't use an unsigned char.
Any help would be most gratefully received.
Here's an example of the error message generated by the make process:
Source/LibRawLite/./internal/dcraw_common.cpp:4543:19: error: constant expression evaluates to 136 which cannot be narrowed to type 'signed char'
[-Wc++11-narrowing]
+1,-1,+1,+1,0,0x88, +1,+0,+1,+2,0,0x08, +1,+0,+2,-1,0,0x40,
^~~~
And here's the code:
void CLASS vng_interpolate()
{
static const signed char *cp, terms[] = {
-2,-2,+0,-1,0,0x01, -2,-2,+0,+0,1,0x01, -2,-1,-1,+0,0,0x01,
-2,-1,+0,-1,0,0x02, -2,-1,+0,+0,0,0x03, -2,-1,+0,+1,1,0x01,
-2,+0,+0,-1,0,0x06, -2,+0,+0,+0,1,0x02, -2,+0,+0,+1,0,0x03,
-2,+1,-1,+0,0,0x04, -2,+1,+0,-1,1,0x04, -2,+1,+0,+0,0,0x06,
-2,+1,+0,+1,0,0x02, -2,+2,+0,+0,1,0x04, -2,+2,+0,+1,0,0x04,
-1,-2,-1,+0,0,0x80, -1,-2,+0,-1,0,0x01, -1,-2,+1,-1,0,0x01,
-1,-2,+1,+0,1,0x01, -1,-1,-1,+1,0,0x88, -1,-1,+1,-2,0,0x40,
-1,-1,+1,-1,0,0x22, -1,-1,+1,+0,0,0x33, -1,-1,+1,+1,1,0x11,
-1,+0,-1,+2,0,0x08, -1,+0,+0,-1,0,0x44, -1,+0,+0,+1,0,0x11,
-1,+0,+1,-2,1,0x40, -1,+0,+1,-1,0,0x66, -1,+0,+1,+0,1,0x22,
-1,+0,+1,+1,0,0x33, -1,+0,+1,+2,1,0x10, -1,+1,+1,-1,1,0x44,
-1,+1,+1,+0,0,0x66, -1,+1,+1,+1,0,0x22, -1,+1,+1,+2,0,0x10,
-1,+2,+0,+1,0,0x04, -1,+2,+1,+0,1,0x04, -1,+2,+1,+1,0,0x04,
+0,-2,+0,+0,1,0x80, +0,-1,+0,+1,1,0x88, +0,-1,+1,-2,0,0x40,
+0,-1,+1,+0,0,0x11, +0,-1,+2,-2,0,0x40, +0,-1,+2,-1,0,0x20,
+0,-1,+2,+0,0,0x30, +0,-1,+2,+1,1,0x10, +0,+0,+0,+2,1,0x08,
+0,+0,+2,-2,1,0x40, +0,+0,+2,-1,0,0x60, +0,+0,+2,+0,1,0x20,
+0,+0,+2,+1,0,0x30, +0,+0,+2,+2,1,0x10, +0,+1,+1,+0,0,0x44,
+0,+1,+1,+2,0,0x10, +0,+1,+2,-1,1,0x40, +0,+1,+2,+0,0,0x60,
+0,+1,+2,+1,0,0x20, +0,+1,+2,+2,0,0x10, +1,-2,+1,+0,0,0x80,
+1,-1,+1,+1,0,0x88, +1,+0,+1,+2,0,0x08, +1,+0,+2,-1,0,0x40,
+1,+0,+2,+1,0,0x10
}, chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 };
...
C++11 prevents 'narrowing conversions' like that. Early versions of C++ would accept them. I think this patch to the source of dcraw_common.cpp should fix it.
https://gist.github.com/conchurnavid/ac19c8e882f1835f0310
There's a duplicate question here. Building FreeImage 3.16.0 for Android
The most usable solution I found to this issue was the following GitHub posting: https://github.com/danoli3/FreeImage. Here some kind soul appears to have successfully built the 3.17.0 library and uploaded it. I've found that works just fine.
Please bear in mind however that it's been built with a hard-coded path of /opt/local/lib - which may be an issue when you come to implementation, since your app will be looking for it there, not bundled with the app. I did find this LiveCode post aided my understanding in that regard a lot.
Hope this helps.

Swift Compiler performance

I got this statement in Swift code which produces an error when executing in playground:
let colors: [String: [Float]] = ["skyBlue" : [240.0/255.0, 248.0/255.0, 255.0/255.0,1.0],
"cWhite" : [250.0/255.0, 250.0/255.0, 250.0/255.0, 1.0]]
The error is : expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions
Then I changed the arrays element type to Double which just works fine.
However I am asking myself why this happens ?
As I said using Double it works just fine. So my guess is that Swift tries to guess the type and therefore Double works better in this example than Float.
Similar issues have been reported before, and (as I understand it) the problem is the automatic type inference for "complicated" expressions. You should file a bug report at Apple.
It compiles with a dictionary of one color, but not with two.
In this concrete case, you can work around it by converting each number in the array to a Float explicitly:
let colors = [
"skyBlue" : [Float(240.0/255.0), Float(248.0/255.0), Float(255.0/255.0),Float(1.0)],
"cWhite" : [Float(250.0/255.0), Float(250.0/255.0), Float(250.0/255.0), Float(1.0)]
]

How to force a raw value of 7 into a UIViewAnimationCurve enum?

The key UIKeyboardAnimationCurveUserInfoKey in the userInfo dictionary of a UIKeyboardWillShowNotification contains an Int with the value 7.
Now I need to pass this Int into UIView.setAnimationCurve(<here>). I tried to create the required UIViewAnimationCurve enum like this UIViewAnimationCurve(rawValue: 7). Because the raw value 7 is undocumented, the result is always nil.
It works fine this way in Objective-C. Any idea how to get this animation curve from the notification into a UIView animation using Swift?
Update:
As pointed out by Martin, this is no longer a problem since Xcode 6.3.
From the Xcode 6.3 Release Notes:
Imported NS_ENUM types with undocumented values, such as UIViewAnimationCurve, can now be converted from their raw integer values using the init(rawValue:) initializer without being reset to nil. Code that used unsafeBitCast as a workaround for this issue can be written to use the raw value initializer.
I think I figured it out, but I'm not sure if this is the way it's supposed to be done.
let animationCurve = unsafeBitCast(7, UIViewAnimationCurve.self)
UIView.setAnimationCurve(animationCurve)
Update: The solution contained in this question works as well.
var animationCurve = UIViewAnimationCurve.EaseInOut
NSNumber(integer: 7).getValue(&animationCurve)

boost object_pool construct method

I'm keen on using boost's object_pool class for memory re-use for a set of video frames.
boost::object_pool< VideoFrame > FramePool;
Now, the VideoFrame class has two constructors. The first version of the constructor takes 4 arguments while the second version takes 6 arguments/parameters.
For every "new" video frame that is allocated, I would like to call the constructor on the object either using the 4 or 6 parameter version. For example:
//VideoFrame *F = new VideoFrame(IdeckLinkOutput, &R, PixelFormat, FrameFlags);
VideoFrame *F = FramePool.construct(IdeckLinkOutput, &R, PixelFormat, FrameFlags);
Building this on MSVS 2005, I receive the error:
error C2660: 'boost::object_pool<T>::construct' : function does not take 4 arguments
According to the documentation on the 'construct' method of object_pool, "ElementType must have a constructor matching ???; the number of parameters given must not exceed what is supported through pool_construct"
I've seen boost's page for the pool_construct, but I'm not too sure the direction I need to take. The build of boost that I have on my machine has both a pool_construct.m4, pool_construct.sh, pool_construct.bat, pool_construct.inc. It's a question of what do I do with these example files within my own project? Would I create my own variation of pool_construct.inc and include that in my own project? How would I add the file?
Any tips/recommendations would be much appreciated. Please note that I have installed gnu's m4.
zerodefect.
If I look at /usr/include/boost/pool/detail/pool_construct.inc on my Debian machine (sorry don't have access to MSVC currently), I see it only supports up to 3 constructor arguments.
Messing with m4 as per the documentation to support more than the supported 3 sounds like a pain compared with simply creating a new constructor which bundles enough of the arguments in a single struct or boost::tuple to bring the total passed down to the number supported.

Resources