Geometric ferroelectricity in rare-earth compounds RGaO3 and RInO3